E
E
Externus2015-04-05 09:42:07
Yii
Externus, 2015-04-05 09:42:07

Yii2. active record. How to group or and and requests?

Good afternoon
How is it better to implement such a query using only the query builder?
( (a like '%1%') and (b like '%2%') )
and
( (a like '%X%') or (b like '%X%') )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Externus, 2015-04-05
@Externus

///$query - activeQuery
$query->filterWhere([
                'and',
                ['and', ['like', 'a', '1' ], ['like', 'b', '2' ]],
                ['or', ['like', 'a', 'x'], ['like', 'b', 'x']],
            ]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question