Hi list,
I have a couple of questions. First question is related to having the possibility to provide arrays in $bind parameter of Zend_Db_Adapter_Abstract::query.
For example:
$sql = "SELECT FROM x WHERE y = ? AND z IN (?)";
$adapter->query( $sql, array( 1, array( 1, 2, 3 ) );
Internally the adapter would modify the query to:
$sql = "SELECT FROM x WHERE y = ? AND z IN (?, ?, ?)";
and the bind array to:
array( 1, 1, 2, 3 );
For a query with named parameters:
$sql = "SELECT FROM x WHERE y = :y AND z IN (:z)";
the adapter would modify the query to:
$sql = "SELECT FROM x WHERE y = :y AND z IN (:z_0001, :z_0002, :z_0003)";
and the bind array to:
array( 'y' => 1, 'z_0001' => 1, 'z_0002' => 2, 'z_0003' => 3 );
Is this an enhancement planned for future releases of Zend Framework?
Right now, I've implemented something like this with the help of a decorator, which leads me to the second question.
What is the easiest/recommended way of adding common functionality to ALL db adapters WITHOUT duplicating code?
My answer to the above question is, as I stated above, the use of a decorator which would intercept the call to the query method, modify it and the bind array and pass it forward to the decorated object. Because there are some drawbacks to this approach I am interested in hearing about other solutions from people who faced problems in adding enhancements to the Zend_Db component.
Thanks.
没有评论:
发表评论