ID: 43457
User updated by: pookey at pookey dot co dot uk
Reported By: pookey at pookey dot co dot uk
Status: Open
-Bug Type: PostgreSQL related
+Bug Type: PDO related
Operating System: linux
PHP Version: 5.2CVS-2007-11-29 (CVS)
New Comment:
moving to PDO related from Postgres related.
Previous Comments:
------------------------------------------------------------------------
[2007-11-29 17:41:05] pookey at pookey dot co dot uk
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 this bug report at http://bugs.php.net/?id=43457&edit=1