Answer the question
In order to leave comments, you need to log in
How to write correct AND (LIKE OR LIKE) query using Query Builder?
I need to write this type of
$query->where(.....);
$query->and(.....)
$query->andFilterWhere(['like','user.first_name',$this->query,['or like','user.middle_name'=>$this ->query],['or like','user.last_name'=>$this->query]]);
The problem is that it only searches for the first field "first_name".
Generated query without OR operator at all
Answer the question
In order to leave comments, you need to log in
$query->andFilterWhere([
'or',
['like', 'user.first_name', 'fName'],
['like', 'user.middle_name', 'mName'],
['like', 'user.last_name', 'lName']
]);
$query->where(.....);
$query->and(.....)
$query->andWhere(...)
$query->orWhere(...);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question