Answer the question
In order to leave comments, you need to log in
How to write "left" and "right" LIKE in ActiveQuery Yii2?
Good afternoon.
I have a very stupid question, but only Yii1 is described in Google, but it does not work on Yii2.
$users = \common\models\User::find()->filterWhere(['like', 'username', '89'])->all();
...`username` LIKE '%89%'...
...`username` LIKE '89%'...
Answer the question
In order to leave comments, you need to log in
www.yiiframework.com/doc-2.0/yii-db-query.html#whe...
For example, ['like', 'name', '%tester', false] will generate name LIKE '%tester'.
That is, you just need to write ['like', 'username', '89%', false]
Conclusion - read the documentation carefully.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question