php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39146 Named placeholder is not bound correctly with Subqueries
Submitted: 2006-10-13 12:29 UTC Modified: 2006-10-15 16:46 UTC
From: php at mailingslists dot birkholz dot biz Assigned:
Status: Closed Package: PDO related
PHP Version: 5.1.6 OS: Linux 2.6.17-gentoo-r7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at mailingslists dot birkholz dot biz
New email:
PHP Version: OS:

 

 [2006-10-13 12:29 UTC] php at mailingslists dot birkholz dot biz
Description:
------------
When binding to a named placeholder in a prepared-statement using mysql-5.0.24-r1 causes unpredictable behaviour.
With PHP 5.1.4 the query goes correct.

Reproduce code:
---------------
<?php

$dbh = new PDO('mysql:host=localhost;dbname=mysql', 'root', 'pwd');

$query1 = "SELECT * FROM user WHERE User=:user AND Host IN (SELECT Host FROM user WHERE User=:user)";
$query2 = "SELECT * FROM user WHERE Host IN (SELECT Host FROM user WHERE User=:user) AND User=:user";

$stm1 = $dbh->prepare($query1);
$stm1->bindValue(':user', 'root');
$stm1->execute();
print count($stm1->fetchAll()).'<br>';

$stm2 = $dbh->prepare($query2);
$stm2->bindValue(':user', 'root');
$stm2->execute();
print count($stm2->fetchAll()).'<br>';


Expected result:
----------------
Should return: (like it does using the command-line-client)

2
2

Actual result:
--------------
It returns:

2
6

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-15 16:46 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 17:01:35 2025 UTC