Bug #63347 [Asn->Nab]: Different behavior of parameters processing
Edit report at https://bugs.php.net/bug.php?id=63347&edit=1
ID: 63347
Updated by: wez@php.net
Reported by: naquad at gmail dot com
Summary: Different behavior of parameters processing
-Status: Assigned
+Status: Not a bug
Type: Bug
Package: PDO related
Operating System: Linux
PHP Version: 5.4.8
Assigned To: wez
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
We can't reimplement the mysql (or any DB) prepared statement support 100% on the
client side. Emulated prepares behave differently and this is one of the ways
that this manifests. This behavior will not be changed. If it is important for
you that this work both ways, then you should write your queries with emulated
prepares turned off.
Previous Comments:
------------------------------------------------------------------------
[2012-10-25 10:15:28] naquad at gmail dot com
Its not bogus. You can change the query to something like 'insert into users(login, password,
screen_name) values(:login, :password, :login)' and issue will be still ok. And if it is
"violated" then why emulated prepares work with this?
------------------------------------------------------------------------
[2012-10-25 10:08:26] uw@php.net
I consider this bogus: SQL syntax violated. Mapping feature abused to create dynamic SQL, which is
against the main argument brought up for PDO's PS fixation.
------------------------------------------------------------------------
[2012-10-25 04:01:44] laruence@php.net
seems native prepare supporting doesn't supports multi-same-name params, it will
faild in the params number checking
------------------------------------------------------------------------
[2012-10-24 14:06:31] naquad at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=63347&edit=1
Thread (5 messages)