2

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 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?

1 Answer 1

13

Try this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.