开发者

Zend_Db_Table: Delete multiple entries

开发者 https://www.devze.com 2023-04-07 04:26 出处:网络
I wanted to delete some db entries and each of them has a unique ID. My current code looks so, taken from here: Zend Framework: How to delete a table row where multiple things are true?

I wanted to delete some db entries and each of them has a unique ID. My current code looks so, taken from here: Zend Framework: How to delete a table row where multiple things are true?

$where = array();
foreach ($IDs as $ID) {
   $where[] = $this->getAdapter()->quoteInto('id = ?', $ID);
}

$this->delete($where);

This is called inside the model class extends by Zend_Db_Table_Abstract. The query looks now like that:

DELETE FROM `shouts` WHERE (id = '10') AND (id = '9') AND (id = '8')

That开发者_如何学C doesn't work of course because of the AND's, this have to be OR's to work correctly, but how could I get this work so?


Try this:

$where = $this->getAdapter()->quoteInto('id IN (?)', $IDs);
$this->delete($where);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号