I have array with ids and want to delete all them by id
$membersId = array('1','2','3');
$inStatement = implode(',', $membersId);
//dont work!
TRatingMembers::model()->deleteAll(array('member_id IN (:member_id)'),
array(':member_id' => $inStatement));
How to delete all rows with one transaction?
$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 . ')');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With