我有带有 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));
如何用一笔交易删除所有行?
我有带有 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
if (!empty(membersId)) {
$memberIds = implode(', ', $membersId);
TRatingMembers::model()->deleteAll('member_id IN (' . $memberIds . ')');
}