|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53475 Query with prepared statement
Submitted: 2010-12-05 06:00 UTC Modified: 2010-12-05 06:12 UTC
From: germanh1982 at gmail dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.3.3 OS: Linux dell 2.6.35-gentoo-r12 #3
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: germanh1982 at gmail dot com
New email:
PHP Version: OS:


 [2010-12-05 06:00 UTC] germanh1982 at gmail dot com
I have the following database with two rows (simplified just to show the issue):

sqlite> select * from bl;
addr  tstamp       
----  -------------
1     10           
2     20           

when running the (prepared) query:
"select * from bl where 30 - tstamp > :param AND :param = :param", with ":param" bound to the value 15, I get no rows as result.

I would expect to receive the row with tstamp = 10 as correct result (as I do if I run the query with the sqlite3 command line client).

SQlite version: 3.7.2

Test script:
$ sqlite3 test.sqlite
sqlite> CREATE TABLE bl (address text unique, tstamp integer not null);

$ sqlite3 test.sqlite
SQLite version 3.7.2
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table bl (address text unique, tstamp integer not null);
sqlite> insert into bl values (1,10);
sqlite> insert into bl values (2,20);

$db = new PDO("sqlite:test.sqlite");
$q = $db->prepare("select * from bl where 30 - tstamp > :param AND :param = :param");
$q->bindValue(":param", 15);

Expected result:
Running the following script, on an sqlite3 shell, I get the following (expected output):
sqlite> select * from bl where 30 - tstamp > 15 AND 15 = 15;
addr  tstamp       
----  -------------
1     10           

The same happens running the following script (note the only difference with the non-working script is that I replaced the first instance of ":param" with the corresponding hard-coded value):
$q = $db->prepare("select * from bl where 30 - tstamp > 15 AND :param = :param");
$q->bindValue(":param", 15);

Actual result:
See description.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-05 06:12 UTC]
-Status: Open +Status: Bogus
 [2010-12-05 06:12 UTC]
$q->bindValue(":param", 15, PDO::PARAM_INT);
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 31 19:01:24 2020 UTC