ZF-3453: Zend_Db_Statement_Mysqli::_execute() binds every parameter as type "s", causing bit type mysql columns (and others?) to fail with "Data too long" error
Description
When Zend_Db_Statement_Mysqli::_execute() prepares parameters types to bind before executing it does the next :
array_unshift($params, str_repeat('s', count($params)));
And when a bit type column value is passed to the statement (for example by Zend_Db_Table_Abstract:insert(), the query will fail with "Data too long for column X".
Proposed solution:
There should be some basic parameter type checking, something like:
$types='';
$numParams=count($params);
for($n=0;$n<$numParams;$n++) {
if (is_numeric($params[$n])) {
if (is_double($params[$n])) {
$types.='d';
}
else {
$types.='i';
}
}
else {
$types.='s';
}
}
array_unshift($params, $types);
Comments
Posted by Mark Evans (sparky) on 2008-12-20T05:19:18.000+0000
Added a patch to correctly identify the parameter types
Posted by Diego Sainz (disago) on 2009-03-19T19:46:39.000+0000
As of ZF 1.7.7 this issue remains unsolved (and the patch is already attached).
The 'nice to have' status sounds inadequate to me because this bug disables the use of Zend_Db_Statement in mysql if bit columns are being used.
Any comments?
Thanks!
Posted by Anthon Pang, VIP Software Technologies Inc. (vipsoft) on 2011-01-12T09:32:16.000+0000
This is still outstanding in 1.11.2, and is inconsistent because it doesn't occur when using Zend_Db_Adapter_Pdo_Mysql.
Posted by Constantine Karnacevych (digital) on 2011-01-12T09:38:59.000+0000
the bug is for Mysqli, not Mysql