ZF-9663: Empty exception message with incorrect parameters for db2_execute()
Description
PHP issues a warning when the parameter count is wrong for db2_execute (line 202 in Zend/Db/Statement/Db2.php). But it is quieted with '@'. That's fine, but db2_stmt_errormsg() and db2_stmt_error() never return anything. The exception message is empty as well.
I predict this is an issue with the PECL module upstream.
The following code produces:
<?php
header('Content-type: text/plain');
require_once 'Zend/Db.php';
try {
$db = Zend_Db::factory('Db2', array('host' => '127.0.0.1',
'username' => 'user',
'password' => '****',
'dbname' => 'database');
$stmt = $db->select()
->from(array('t' => 'table'),
array('id'))
->where('name = ?');
$result = $db->fetchAll($stmt, array(/* warning condition */));
foreach ($result as $row) {
foreach ($row as $col => $val) {
printf(" %s: %s\n", $col, $val);
}
printf("--\n");
}
} catch (Zend_Exception $e) {
echo 'Caught exception of type: ' . get_class($e) . "\n";
echo 'Error message: ' . $e->getMessage() . "\n";
}
?>
Here's the result:
Caught exception of type: Zend_Db_Statement_Db2_Exception Error message:
The Pdo_Mysql driver does this:
Caught exception of type: Zend_Db_Statement_Exception Error message: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
Comments
Posted by Aaron S. Hawley (ashawley) on 2010-04-16T12:07:22.000+0000
I've posted a bug to the ibm_db2 PECL extension.
http://pecl.php.net/bugs/17226
Cross your fingers!