Answer the question
In order to leave comments, you need to log in
(YII2) How to arrange AR search when searching for multiple values of one parameter?
Good day.
It is required to solve a problem: in AR search, more than 1 value must be processed at a time to search by parameter.
There is a city column. Enter in the search: Kazan, Samara, Rostov, etc. through the separator. The search processes each of the cities and outputs matches.
In the Search model, it was not possible to organize the foreach iteration. We split the request through 'explode' by comma and sent it to the loop.
foreach ($array as $city_str) {
$query->andFilterWhere(['like', 'city', $city_str]);
Answer the question
In order to leave comments, you need to log in
I understand that instead
it should be
, or most likely like this:
$query->andFilterWhere(['or',
['like', 'city', $city_str1],
['like', 'city', $city_str2],
....
['like', 'city', $city_str999],
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question