ZF-651: Bind inconsistent in query() versus update()/delete().

Description

Zend_Db_Adapter_Abstract::query(), Zend_Db_Select::where(), etc. allow you to bind variables to $sql/$where. However, in Zend_Db_Adapter_Abstract::update(), Zend_Db_Adapter_Abstract::delete(), Zend_Db_Table::update() and Zend_Db_Table::delete() it will not bind any variables to the $where variable.

Furthermore, Zend_Db_Table::fetchAll() and Zend_Db_Table::fetchOne() allow you to bind variables to $where, but you'd have to pass it as the values in the $where array rather than using a separate $bind variable, and you can only use question mark placeholders in those.

Unless this was done deliberately, it'd be nice if Zend_Db_Adapter_Abstract, Zend_Db_Select, and Zend_Db_Table would all use the same interface for binding variables. Essentially, always use a separate $bind variable to allow you to bind using either question mark placeholders or named placeholders.

It'd also be nice if one could directly pass arrays as one of the bind values (i.e. $bind would be an array of arrays) in all the aforementioned functions and it'd substitute a comma-separated list of values, just like how Zend_Db_Adapter_Abstract::quote() does it.

Again, if this is done by design then that's fine with me, so in that case just ignore this ticket. It's just that the different ways that variables need to be bound makes things a bit confusing.

Comments

Assigning to Bill Karwin. Scheduling for 0.8.

Assigning to Bill Karwin.

For Table::fetchAll(), we already have four optional parameters, and additional optional parameters would certainly take away from the simplicity of using the method.

For Table::update() and delete(), the $where parameter may be an array, and therefore, the usage of binding variables here would be difficult to document and to use, as the interface becomes more complex.

bq. For Table::update() and delete(), the $where parameter may be an array, and therefore, the usage of binding variables here would be difficult to document and to use, as the interface becomes more complex.

But when you add third argument like Zend_Db_Table_Abstract::update(array $data, $where, $bind = array()) is it still possible to use method as it was before and in new way, for example:


class Table1 extends Zend_Db_Table_Abstract  {}

$t = new Table1();

$t->update(array('a', 'b'), array('id = ?'), 2); //for only one parameter it doesn't have to be array
$t->update(array('a', 'b'), array('id = ?', 'active = ?'), array(2, 1));

What do you think about this idea?

Bookkeeping. Closing old issues and assigning them to the person who ultimately resolved the issue.