|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-05-10 05:59 UTC] bhoehl at linotype dot com
Description:
------------
It is not possible to use a supplied value more than once for one prepared statement.
See error and code below.
Reproduce code:
---------------
create table a (key1 int) ;
create table b (key2 int) ;
insert into a values(1) ;
insert into b values(1) ;
<?php>
$dbh = new PDO('mysql:host=somehost;dbname=somedb', 'user', 'password');
$res = $dbh->prepare('select * from a where key1 = :value union select * from b where key2 = :value') ;
$x = 1 ;
$res->bindParam(':value', $x) ;
$res->execute() ;
print_r($res->fetchAll()) ;
?>
Expected result:
----------------
Array
(
[0] => Array
(
[key1] => 1
[0] => 1
)
)
Actual result:
--------------
Array
(
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 22:00:01 2025 UTC |
BTW. I tried it with the postgres PDO driver using $dbh = new PDO('pgsql:host=somehost;dbname=somedb', 'user', 'password'); and this stuff is working as expected. Is that depending on the mysql server ?