|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43457 prepared statement with incorrect parms doens't throw exception
Submitted: 2007-11-29 17:41 UTC Modified: 2007-12-02 21:00 UTC
From: pookey at pookey dot co dot uk Assigned:
Status: Closed Package: PDO related
PHP Version: 5.2CVS-2007-11-29 (CVS) OS: linux
Private report: No CVE-ID:
 [2007-11-29 17:41 UTC] pookey at pookey dot co dot uk
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


  $pdo = new PDO('pgsql:dbname=mmm user=mmm');

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

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

  $ret = $stmt2->execute( array(
    ':param1'     => 'wibble',
    ':nonsense'  => 1,

Expected result:
exception thrown

Actual result:
$ ~pookey/src/php5/sapi/cli/php ./test.php
array(3) {
  string(5) "HY093"
  string(0) ""


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-30 01:54 UTC] pookey at pookey dot co dot uk
moving to PDO related from Postgres related.
 [2007-12-02 21:00 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Oct 04 05:01:29 2015 UTC