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

后端 未结 3 444
不思量自难忘°
不思量自难忘° 2020-12-05 10:35

Normally, this would work for me:

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


        
3条回答
  •  一整个雨季
    2020-12-05 10:56

    From the zend manual on delete():

    If you omit the second argument, the result is that all rows in the database table are deleted.

    If you provide an array of strings as the second argument, these strings are joined together as terms in an expression separated by AND operators.

    If you provide an array of arrays as the second argument, the the values will be automatically quoted into the keys. These will then be joined together as terms, seperated by AND operators.

    Not exactly sure what the 3rd section is saying, but the 2nd implies that you can do:

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

提交回复
热议问题