|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-30 01:54 UTC] pookey at pookey dot co dot uk
[2007-12-02 21:00 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 09 04:00:01 2025 UTC |
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) "" }