I want write a Following Query in Active record .
SELECT *
FROM `User`
WHERE `UserId`
IN ( 6, 7, 8, 9 ) ;
Thanks
If you want to get your query faster, use Command Builder:
Yii::app()->db->createCommand()
->select('*')
->from('user')
->where(array('in', 'UserId', array(6, 7, 8, 9)))
->queryAll();
To get it via CActiveRecord, use findAllByAttributes
User::model()
->findAllByAttributes(array(
'UserId' => array(6,7,8,9)
));
But it will get full object of User with all associated relations, so it's slower.