From: naquad at gmail dot com
Operating system: Linux
PHP version: 5.4.8
Package: PDO related
Bug Type: Bug
Bug description:Different behavior of parameters processing
Description:
------------
PDO::ATTR_EMULATE_PREPARES changes behavior of parameter processing.
When it is enabled multiple occurrences of named parameter work as
expected, but
when it is disabled I get "Invalid parameter number" error.
Test script:
---------------
<?php
$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); /// remove this
line and scirpt works as expected
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $pdo->prepare('select :x = :x');
$query->bindValue(':x', 1);
$query->execute();
$t = $query->fetch();
var_dump($t);
$query->closeCursor();
Expected result:
----------------
array(2) {
'\'1\' = \'1\'' =>
string(1) "1"
[0] =>
string(1) "1"
}
Actual result:
--------------
PDOException: SQLSTATE[HY093]: Invalid parameter number in
/srv/http/fucktube/app/test.php on line 7
Call Stack:
0.0002 230552 1. {main}() /srv/http/fucktube/app/test.php:0
0.0739 246416 2. PDOStatement->execute()
/srv/http/fucktube/app/test.php:7
--
Edit bug report at https://bugs.php.net/bug.php?id=63347&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=63347&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=63347&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=63347&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=63347&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=63347&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=63347&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=63347&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=63347&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=63347&r=support
Expected behavior: https://bugs.php.net/fix.php?id=63347&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=63347&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=63347&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=63347&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63347&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=63347&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=63347&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=63347&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=63347&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=63347&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=63347&r=mysqlcfg