Alimon Karim
Alimon Karim

Reputation: 4469

How to get another model data in cakephp without relation?

I have two table patients and diagnosis in patients add form I am trying to search diagnosis list for making a cart.Here they have no any relation. Output like this

enter image description here

I have tried bellow code for search this item

In patients/add

 <?php
   echo $this->Form->input('Search',array( 'class'=>'form-control','label' => false,'placeholder'=>'Search Diagnosis Name By Name','id'=>'search','style'=>"border:1px solid gray;"));
 ?>

Then I have applied bellow jquery code.

$('#search').keyup(function(){
            var value=$('#search').val();

            $.get("<?php echo   Router::url(array('controller'=>'Patients','action'=>'dsearch'));?>",{search:value},function(data){
                                $('.search_data').html(data);
            });
      });

In patients controller I have written bellow method,I have used loadModel in here but it's not working.

public function dsearch()
    {
            $this->loadModel('Diagnosi');
            if(isset($this->request->query['search'])){
            $search = $this->request->query['search'];
        }
        else{
                $search = '';
            }
        $this->Paginator->settings = array(
            'conditions' => array('Diagnosi.name LIKE' => "%$search%"),
            'limit'=>4
        );
        $this->set('diagnosis',$this->Paginator->paginate());
    }

Here it's searching name field from diagnosis if there have a relation.How I can search this without using relation model.

Upvotes: 0

Views: 225

Answers (1)

Salines
Salines

Reputation: 5767

$this->set('diagnosis',$this->Paginator->paginate('Diagnosi'));

Upvotes: 1

Related Questions