我一直在使用cakephp paginations选项2天.我需要创建一个INNER联接列出几个字段,但我必须处理搜索以过滤结果.这是我处理搜索选项的代码的一部分$this->passedArgs
function crediti() {
if(isset($this->passedArgs['Search.cognome'])) {
debug($this->passedArgs);
$this->paginate['conditions'][]['Member.cognome LIKE'] = str_replace('*','%',$this->passedArgs['Search.cognome']);
}
if(isset($this->passedArgs['Search.nome'])) {
$this->paginate['conditions'][]['Member.nome LIKE'] = str_replace('*','%',$this->passedArgs['Search.nome']);
}
Run Code Online (Sandbox Code Playgroud)
之后
$this->paginate = array(
'joins' => array(array('table'=> 'reservations',
'type' => 'INNER',
'alias' => 'Reservation',
'conditions' => array('Reservation.member_id = Member.id','Member.totcrediti > 0' ))),
'limit' => 10);
$this->Member->recursive = -1;
$this->paginate['conditions'][]['Reservation.pagamento_verificato'] = 'SI';
$this->paginate['fields'] = array('DISTINCT Member.id','Member.nome','Member.cognome','Member.totcrediti');
$members = $this->paginate('Member');
$this->set(compact('members'));
Run Code Online (Sandbox Code Playgroud)
INNER JOIN工作得很好,但$ this-> paginations忽略了每一个$this->paginate['conditions'][] by $this->passedArgs,我不知道如何解决它.调试中没有查询,只是原始查询INNER JOIN.有人可以帮助我吗?非常感谢你
更新:没有运气.我已经处理了这部分代码很长时间了.如果我使用
if(isset($this->passedArgs['Search.cognome'])) {
$this->paginate['conditions'][]['Member.cognome LIKE'] = str_replace('*','%',$this->passedArgs['Search.cognome']);
}
$this->paginate['conditions'][]['Member.sospeso'] …Run Code Online (Sandbox Code Playgroud) cakephp ×1