|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35824 prepared quries returning 0 rows with variable in multiple places
Submitted: 2005-12-28 01:39 UTC Modified: 2005-12-28 08:28 UTC
From: xing at mac dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.1.2RC1 OS: centos 4.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: xing at mac dot com
New email:
PHP Version: OS:


 [2005-12-28 01:39 UTC] xing at mac dot com
Mysql version 4.1.15

use mysql_pdo with attribute enabled to have it throw exception on all errors:

Reproduce code:
$st = $db->prepare("select * from test where c = 2 AND (a = :a OR b =

$st->execute(array(":a" => 2));

Expected result:
Rows matching where a == 2 or b == 2 OR an exception if pdo doesn't support having the same variable appear more than once in a prepared query.

Actual result:
0 row result regardless of what's in the database. No error or
exceptions from pdo. Everything points to successful query when nothing has been executed.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-28 08:28 UTC] xing at mac dot com
Turns out it's because I did not set the error attribute correctly. Apparently you cannot set it via the construct method.

new PDO("mysql:host=;unix_socket=/tmp/my.sock;dbname=testdb",

the above does not set the error mode attribute..had to use the below after pdo connection is made.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 11:01:32 2024 UTC