当我尝试使用此代码时,这适用于手机领域。
$this->Paginator->settings = array(
'conditions' =>array( 'OR'=>array(
array('user.id'=>$search),
array('user.email' =>$email),
array('user.phone LIKE' =>'%'.$phone.'%'),
array('user.name_kana' =>$sname),
array('user.name' =>$name),
)),
'limit'=>4
);
但是,如果我尝试多次LIKE没有任何工作,它将获取所有结果。
$this->Paginator->settings = array(
'conditions' =>array( 'OR'=>array(
array('user.id'=>$search),
array('user.email LIKE' =>'%'.$email.'%'),
array('user.phone LIKE' =>'%'.$phone.'%'),
array('user.name_kana' =>$sname),
array('user.name' =>$name),
)),
'limit'=>4
);
有什么不对吗?
答案 0 :(得分:0)
试试这个
$this->Paginator->settings = array(
'conditions' =>array( 'OR'=>array(
"user.id"=>$search,
"user.email LIKE" =>'%'.$email.'%',
"user.phone LIKE" =>'%'.$phone.'%',
"user.name_kana" =>$sname,
"user.name" =>$name,
)),
'limit'=>4
);
希望这会很好。
答案 1 :(得分:-1)
请尝试此代码
$this->Paginator->settings = array(
'conditions' =>array( 'OR'=>array(
array('user.id'=>$search),
array('user.email LIKE' =>"%$email%"),
array('user.phone LIKE' =>"%$phone%"),
array('user.name_kana' =>$sname),
array('user.name' =>$name),
)),
'limit'=>4
);