P
P
Pavel Gogolinsky2014-04-20 15:52:47
MySQL
Pavel Gogolinsky, 2014-04-20 15:52:47

How to use SQL IN operator in active records in yii?

How to use active records in yii to make a query like
"Select all records that have a number from the array (1,2,3) in the 'pole_1' field, and a number from the array (4,5,6) in the 'pole_2' field" ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2014-04-20
@gogolinsky

User::model()->findAllByAttributes(['pole_1' => [1,2,3], 'pole_2' => [4,5,6]]);

V
Vit, 2014-04-20
@fornit1917

For example, CDbCriteria has an addInCondition method.
Also findAllByAttributes understands arrays as values

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question