【问题标题】:Zend_Db_Table: Delete multiple entriesZend_Db_Table:删除多个条目
【发布时间】:2011-09-25 23:04:27
【问题描述】:

我想删除一些数据库条目,每个条目都有一个唯一的 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's,这必须是OR's 才能正常工作,但我怎么能这样工作呢?

【问题讨论】:

    标签: zend-framework zend-db zend-db-table


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 2012-02-16
      • 1970-01-01
      • 2013-10-11
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 2019-10-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多