Issues

ZF-6894: Incompatibile Zend_Db::delete() behavior when string array key is used in where condition

Description

There is an unexpected behavior / critical incompatibility using delete method of Zend_Db. When parameter $where is an array('article_id' => 'article_id=123') whole table is emptied instead of deleting a single record with an article_id=123.

Example:

$where = array('article_id' => 'article_id=123'); $this->db->delete('MY_TABLE', $where);

ZF 1.7.8: row with article_id=123 is deleted ZF 1.8.2: result: MY_TABLE is emptied

The behavior is caused by the 'string' array key. If numeric key is used the problem is avoid.

Comments

In Zend/Db/Adapter/Abstract.php on line 659 you can see this: $term = $this->quoteInto($cond, $term);

Using array('article_id' => 'article_id=123') will cause a where query like "WHERE article_id" without any binding. The correct array binding should be array('article_id = ?' => 123).

In my opinion, if the ZF developer team changes this behavior in order to preverse BC, it will introduce unpredictable results.

Closing as not an issue, as noted above, the correct and documented notation would be array('field = ?' => $value)