From:             pookey at pookey dot co dot uk
Operating system: linux
PHP version:      5.2CVS-2007-11-29 (CVS)
PHP Bug Type:     PostgreSQL related
Bug description:  prepared statement with incorrect parms doens't throw 
exception

Description:
------------
no exception is thrown when using named params to a prepared statement, 
when you pass invalid names.

Interestingly, is that count of the params doesnt' match, an exception is
thrown.

Using the code below, but using sqlite instead..

  $pdo = new PDO('sqlite::memory:');

then you do get an exception

# php ./test.php

PDOException: SQLSTATE[HY000]: General error: 25 bind or column index out
of range in /tmp/test.php on line 16

Call Stack:
    0.0002     103296   1. {main}() /tmp/test.php:0
    0.0014     106912   2. PDOStatement->execute() /tmp/test.php:16

I've not tested with other DBMSs.


Reproduce code:
---------------
 $ cat ./test.php
<?php

  error_reporting(E_ALL);

  $pdo = new PDO('pgsql:dbname=mmm user=mmm');
  $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  $pdo->exec('CREATE TABLE test ( field1 varchar, field2 varchar)');

  $stmt2 = $pdo->prepare('INSERT INTO test (field1, field2) VALUES
(:param1, :param2)');

  $pdo->beginTransaction();
  $ret = $stmt2->execute( array(
    ':param1'     => 'wibble',
    ':nonsense'  => 1,
  ));
  var_dump($ret);
  var_dump($stmt2->errorInfo());


Expected result:
----------------
exception thrown

Actual result:
--------------
$ ~pookey/src/php5/sapi/cli/php ./test.php
bool(false)
array(3) {
  [0]=>
  string(5) "HY093"
  [1]=>
  int(7)
  [2]=>
  string(0) ""
}


-- 
Edit bug report at http://bugs.php.net/?id=43457&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43457&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43457&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43457&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43457&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43457&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43457&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43457&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43457&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43457&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43457&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43457&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43457&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43457&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43457&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43457&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43457&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43457&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43457&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43457&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43457&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43457&r=mysqlcfg

Reply via email to