In MySql you can do a query like:
SELECT * FROM posts WHERE id IN (1,2,6,9,12)
What’s the best AR alternative for doing this?
I looked at findByAttributes but I don’t see how I can apply the ‘IN’ clause
In MySql you can do a query like:
SELECT * FROM posts WHERE id IN (1,2,6,9,12)
What’s the best AR alternative for doing this?
I looked at findByAttributes but I don’t see how I can apply the ‘IN’ clause
Under findByAttributes is says:
So in theory you can do:
Post::model()->findByAttributes(array('id' => array(1,2,6,9,12)));
Hope this helps,
EDIT: Just noticed you actually want findAllByAttributes()
Also:
CActiveRecord::findAllByPk()
or
CDbCriteria::addInCondition()
Thanks Sammaye and Mike. Tried them all, findAllByAttributes() is working perfectly