Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: 1.10.3
-
Fix Version/s: None
-
Component/s: Zend_Db_Adapter_Db2
-
Labels:None
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
I've posted a bug to the ibm_db2 PECL extension.
http://pecl.php.net/bugs/17226
Cross your fingers!