Zend Framework: How to delete a table row where multiple things are true?

Andrew picture Andrew · Dec 4, 2009 · Viewed 48k times · Source

Normally, this would work for me:

$db = Zend_Db_Table::getDefaultAdapter();
$where = $db->quoteInto('id = ?', $id);
$db->delete('tablename', $where);

but I have to match two ids. So I don't really know how to structure it.

WHERE first_id = 'id1' AND second_id = 'id2'

So how do I do this with the Zend Framework?

Answer

smack0007 picture smack0007 · Dec 4, 2009

To extend on Jason W's answer:

Not exactly sure what the 3rd section is saying

That means you can do this:

$db->delete('tablename', array(
    'first_id = ?' => $first_id,
    'second_id = ?' => $second_id
));

And the adapter will quote everything for you.

I don't feel like the documentation is very clear though.