Yii:deleteAll和IN语句

前端之家收集整理的这篇文章主要介绍了Yii:deleteAll和IN语句前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有带有ID的数组,并希望通过id删除它们
$membersId = array('1','2','3');
$inStatement = implode(',',$membersId);

//dont work!
TRatingMembers::model()->deleteAll(array('member_id IN (:member_id)'),array(':member_id' => $inStatement));

如何用一个事务删除所有行?

$criteria = new CDbCriteria;
$criteria->addInCondition('member_id',$membersId);
TRatingMembers::model()->deleteAll($criteria);

http://www.yiiframework.com/doc/api/1.1/CDbCriteria#addInCondition-detail

猜你在找的PHP相关文章