Yuはクエリ式を使用する必要がありますが、これはページング配列では実行できません。
だからNDNの提案に続き、ここで私は
カスタムファインダーを作成するでしょう方法です。あなたのUsersTableファイル
public function findByKeyword(Query $query, array $options)
{
$keyword = $options['keyword'];
$query->where(
function ($exp, $q) use($keyword){
$conc = $q->func()->concat([
'Users.fname' => 'literal', ù
'Users.lname' => 'literal']);
return $exp
->or_([
'Users.fname LIKE' => "%$keyword%",
'Users.lname LIKE' => "%$keyword%",
])
->like($conc, "%$keyword%");
}
);
return $query;
}
コントローラ
$this->paginate = [
'finder' => [
'byKeyword' => [
'keyword' => $this->request->data['Users']['keyword']
]],
'conditions' => $limo, // this will merge your $limo conditions
// with the ones you set in the custom finder
'order'= > ['Users.fname desc'],
];
$this->set('userlist', $this->paginate($this->Users));
ではこれが動作します。ありがとう。私はまた、2番目のlikeパラメータを(他の誰かが同じ問題を抱えている場合に)変更しました:like($ conc、 '%'。$ terms。 '%'); – toast