S
S
shitprog2019-01-25 10:18:29
Yii
shitprog, 2019-01-25 10:18:29

How to generate parameters for a request?

There is a selection condition:

$query->andFilterWhere(['or',
  ['like', 'tags', 'tag1'],
  ['like', 'tags', 'tag2']
]);

How can I form this part by enumerating the received tags from the request?
['like', 'tags', 'tag1'],
['like', 'tags', 'tag2']

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Izmailov, 2019-01-25
@shitprog

As an option

foreach($tags as $tag) {
    $conditions[] = ['like', 'tags', $tag];
}
$query->andFilterWhere(array_merge(['or'], $conditions));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question