Edit report at https://bugs.php.net/bug.php?id=63347&edit=1

 ID:                 63347
 Updated by:         u...@php.net
 Reported by:        naquad at gmail dot com
 Summary:            Different behavior of parameters processing
 Status:             Assigned
 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:

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.


Previous Comments:
------------------------------------------------------------------------
[2012-10-25 04:01:44] larue...@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

Reply via email to