PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #33886 PDO Prepared Statement fails if binding id (:blah) is used more then once.
Submitted:27 Jul 2005 3:57pm UTC Modified: 27 Jul 2005 4:20pm UTC
From:wb at pro-net dot co dot uk Assigned to:
Status:Wont fix Category:PDO related
Version:5.0.4 OS:FreeBSD 5.4-RELEASE-p2
Votes:10 Avg. Score:4.6 ± 0.7 Reproduced:7 of 7 (100.0%)
Same Version:1 (14.3%) Same OS:1 (14.3%)
View/Vote Developer Edit Submission

Have you experienced this issue?
Rate the importance of this bug to you:

[27 Jul 2005 3:57pm UTC] wb at pro-net dot co dot uk
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

[27 Jul 2005 4:00pm UTC] wb at pro-net dot co dot uk
Using PDO-0.9 and PDO_PGSQL-0.9
[27 Jul 2005 4:04pm UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

[27 Jul 2005 4:13pm UTC] wez@php.net
It's not portable to rely on that.
You need to create three parameters and bind them separately.
[27 Jul 2005 4:20pm UTC] wb at pro-net dot co dot uk
Fair enougth.

I will submit a note to the php manual about this.

Keep up the good work :)

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC