Answer the question
In order to leave comments, you need to log in
How to make case insensitive search in yii2?
The database contains a product code, for example CODE1, if you write in caps - it will find it, code1 does not find it.
action snippet:
$q = trim(Yii::$app->request->get('q'));
$query = Product::find()->where(['like', 'name', $q])->orWhere(['like binary', 'id', $q]);
Answer the question
In order to leave comments, you need to log in
like binary just indicates that the search is case-sensitive.
In general, the search there is just case insensitive if the encoding is utf8_general_ci (ci - just means case insensitive)
php.net/mb_strtolower
php.net/manual/ru/function.mb-strtoupper.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question