Issues

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:

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:

<pre class="highlight">
<?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:

<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

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!

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

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

Contacts