如何在没有关系的情况下在cakephp中获取另一个模型数据?
How to get another model data in cakephp without relation?
我有两个 table 患者和诊断患者添加表格我正在尝试搜索诊断列表以制作 cart.Here 他们没有任何关系。像这样输出
我已经尝试使用下面的代码来搜索这个项目
在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;"));
?>
然后我应用了以下 jquery 代码。
$('#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);
});
});
我在 patients controller 中写了下面的方法,我在这里使用了 loadModel 但它不起作用。
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());
}
这是从诊断中搜索名称字段,如果有 relation.How 我可以在不使用关系模型的情况下搜索它。
$this->set('diagnosis',$this->Paginator->paginate('Diagnosi'));
我有两个 table 患者和诊断患者添加表格我正在尝试搜索诊断列表以制作 cart.Here 他们没有任何关系。像这样输出
我已经尝试使用下面的代码来搜索这个项目
在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;"));
?>
然后我应用了以下 jquery 代码。
$('#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);
});
});
我在 patients controller 中写了下面的方法,我在这里使用了 loadModel 但它不起作用。
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());
}
这是从诊断中搜索名称字段,如果有 relation.How 我可以在不使用关系模型的情况下搜索它。
$this->set('diagnosis',$this->Paginator->paginate('Diagnosi'));