how to used IN & Between Clause in YII ACtive Record?

后端 未结 7 1756
轻奢々
轻奢々 2021-02-14 10:15

I want write a Following Query in Active record .

SELECT *
FROM `User`
WHERE `UserId`
IN ( 6, 7, 8, 9 ) ;

Thanks

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-14 10:30

    Either you can use addInCondition or you can also use compare method.

     $criteria = new CDbCriteria();
     $criteria->compare('UserId',array(6,7,8,9));
     $userDataObj = User::model()->findAll($criteria);
    

提交回复
热议问题