Bug #69257 [NEW]: Error on PDO MySQL non-emulated statements and repeating the same named param
| From: | jrbasso at gmail dot com | Date: | Wed, 18 Mar 2015 16:00:39 +0000 |
| Subject: | Bug #69257 [NEW]: Error on PDO MySQL non-emulated statements and repeating the same named param | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191450@lists.php.net to get a copy of this message | ||
From: jrbasso at gmail dot com
Operating system: Any
PHP version: 5.6.6
Package: PDO MySQL
Bug Type: Bug
Bug description:Error on PDO MySQL non-emulated statements and repeating the same named param
Description:
------------
When using prepared statements with named parameters that repeats in the
statement work fine in emulated prepared statements, but doesn't work in
non-emulated mode.
The test script is a simple way to reproduce it.
Test script:
---------------
<?php
$pdo = new
PDO('mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=test;charset=utf8',
'test', 'test');
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('SELECT :a = :a');
$stmt->bindValue(':a', 1, PDO::PARAM_INT);
$stmt->execute();
var_dump($stmt->fetchAll(PDO::FETCH_COLUMN));
Expected result:
----------------
array(1) {
[0]=>
string(1) "1"
}
Actual result:
--------------
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY093]: Invalid parameter number' in
/home/vagrant/shared/test.php:10
Stack trace:
#0 /home/vagrant/shared/test.php(10): PDOStatement->execute()
#1 {main}
thrown in /home/vagrant/shared/test.php on line 10
--
Edit bug report at https://bugs.php.net/bug.php?id=69257&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69257&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69257&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69257&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69257&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69257&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69257&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69257&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69257&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69257&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69257&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69257&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69257&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69257&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69257&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69257&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69257&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69257&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69257&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69257&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69257&r=mysqlcfg