From: wb at pro-net dot co dot uk
Operating system: FreeBSD 5.4-RELEASE-p2
PHP version: 5.0.4
PHP Bug Type: PDO related
Bug description: PDO Prepared Statement fails if binding id (:blah) is used
more then once.
Description:
------------
When using the same binding id in a query the PDOStatement::execute()
method still requires you to specify the same amount of parameters.
Reproduce code:
---------------
<?php
$pdo = new PDO('pgsql:host=localhost dbname=bats user=user
password=pass');
$pdo->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
$statement = $pdo->prepare("
UPDATE groups
SET
lft = CASE WHEN lft > :right
THEN lft + 2
ELSE lft END,
rgt = CASE WHEN rgt >= :right
THEN rgt + 2
ELSE rgt END
WHERE
rgt >= :right
");
$statement->execute(array(':right' => 5));
?>
Expected result:
----------------
Would expect the statement to execute without issue.
Actual result:
--------------
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[08P01]: <<Unknown error>>: 7 ERROR: bind message supplies 1
parameters, but prepared statement "pdo_pgsql_stmt_08257c0c" requires 3'
in /usr/home/wb/bats/scripts/tests/pdoQuery.php:17
Stack trace:
#0 /usr/home/wb/bats/scripts/tests/pdoQuery.php(17):
PDOStatement->execute(Array)
#1 {main}
thrown in /usr/home/wb/bats/scripts/tests/pdoQuery.php on line 17
--
Edit bug report at http://bugs.php.net/?id=33886&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33886&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33886&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33886&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33886&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33886&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33886&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33886&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33886&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33886&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33886&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33886&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33886&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33886&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33886&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33886&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33886&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33886&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33886&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33886&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33886&r=mysqlcfg