From:             
Operating system: archlinux x86_64
PHP version:      5.3.8
Package:          PDO related
Bug Type:         Bug
Bug description:"Invalid parameter number" although it is correct

Description:
------------
When I execute the attached test script an exception is thrown with the
message:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does
not match number of tokens

The exception is raised in the execute() line.

If you change the WHERE clause to `id`=24 there is no error message.
The same is true for this query: UPDATE `edtable` SET `id`=:p0 WHERE
`id`='24'

The generated error message is obviously not correct. I don't even see why
an error message is generated as the request seems valid (although strange)
to me.

Test script:
---------------
$createTableSql = <<<'EOT'
DROP TABLE IF EXISTS `edtable`;
CREATE TABLE IF NOT EXISTS `edtable` (
  `id` bigint(20) NOT NULL,
  `coun't()` varchar(20) NOT NULL
);
EOT;

  $pdo = new PDO('mysql:host=localhost;dbname=aynte','aynte','aynte');
  $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

  $result = $pdo->query($createTableSql);
  $result->closeCursor();

  $stmt = $pdo->prepare("UPDATE `edtable` SET `id`=:p0, `coun't()`= :p1
WHERE `id`='24'");
  $stmt->execute(array(':p0'=>'2', ':p1'=>'b2' ));

Expected result:
----------------
No error message.

Actual result:
--------------
PHP Fatal error:  Uncaught exception 'PDOException' with message
'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does
not match number of tokens' in /srv/http/test.php:19\nStack trace:\n#0
/srv/http/test.php(19): PDOStatement->execute(Array)\n#1 {main}\n  thrown
in /srv/http/test.php on line 19

-- 
Edit bug report at https://bugs.php.net/bug.php?id=60515&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60515&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60515&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60515&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60515&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60515&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60515&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60515&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60515&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60515&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60515&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60515&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60515&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60515&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60515&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60515&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60515&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60515&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60515&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60515&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60515&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60515&r=mysqlcfg

Reply via email to