Answer the question
In order to leave comments, you need to log in
How to form an ActiveQuery YII2 query?
I need to organize a request like:
SELECT * FROM table WHERE pole=value AND (pole1=value1 OR pole2=value2)
Answer the question
In order to leave comments, you need to log in
Table::find()->where(['and', 'pole=value', ['or', 'pole1=value1', 'pole2=value2']])->findAll()
Possible variant:
$query->where('pole = :value and (pole1 = :value1 or pole2 = :value2)');
$query->params([':value'=>"value", ':value1' => 'value1', ':value2' => 'value2']);
$query->params([':value'=>"value", ':value1' => 'value1', ':value2' => 'value2']);
$query->Where(['and', 'value = :value', ['or', 'value1 = :value1', 'value2 = :value2']]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question