ZF-9663: Empty exception message with incorrect parameters for db2_execute()

Issue Type: Bug Created: 2010-04-12T12:03:51.000+0000 Last Updated: 2012-11-20T21:37:24.000+0000 Status: Open Fix version(s): Reporter: Aaron S. Hawley (ashawley) Assignee: None Tags: - Zend_Db_Adapter_Db2

Related issues: Attachments:


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:

<pre class="highlight">
header('Content-type: text/plain');

require_once 'Zend/Db.php';

try {
  $db = Zend_Db::factory('Db2', array('host' => '',
                                      'username' => 'user',
                                      'password' => '****',
                                      'dbname' => 'database');

  $stmt = $db->select()
      ->from(array('t' => 'table'),
      ->where('name = ?');

  $result = $db->fetchAll($stmt, array(/* warning condition */));

  foreach ($result as $row) {
    foreach ($row as $col => $val) {
      printf("  %s: %s\n", $col, $val);
} catch (Zend_Exception $e) {
  echo 'Caught exception of type: ' . get_class($e) . "\n";
  echo 'Error message: ' . $e->getMessage() . "\n";

Here's the result:

<pre class="literal">
Caught exception of type: Zend_Db_Statement_Db2_Exception
Error message: 

The Pdo_Mysql driver does this:

<pre class="literal">
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


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.

Cross your fingers!

Have you found an issue?

See the Overview section for more details.


© 2006-2021 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.