我想删除一些数据库条目,每个条目都有一个唯一的 ID。我当前的代码看起来是这样的,取自这里: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);
这是在 Zend_Db_Table_Abstract 扩展的模型类内部调用的。 查询现在看起来像这样:
DELETE FROM `shouts` WHERE (id = '10') AND (id = '9') AND (id = '8')
这当然行不通,因为 AND
,这必须是 OR
才能正常工作,但我怎么能这样工作呢?
最佳答案
试试这个:
$where = $this->getAdapter()->quoteInto('id IN (?)', $IDs);
$this->delete($where);
关于zend-framework - Zend_Db_Table : Delete multiple entries,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7549217/