Bug #53475 [NEW]: Query with prepared statement
| From: | germanh1982 at gmail dot com | Date: | Sun, 05 Dec 2010 05:00:01 +0000 |
| Subject: | Bug #53475 [NEW]: Query with prepared statement | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-156760@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux dell 2.6.35-gentoo-r12 #3
PHP version: 5.3.3
Package: PDO related
Bug Type: Bug
Bug description:Query with prepared statement
Description:
------------
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);
=====
<?php
$db = new PDO("sqlite:test.sqlite");
$q = $db->prepare("select * from bl where 30 - tstamp > :param AND :param =
:param");
$q->bindValue(":param", 15);
$q->execute();
print_r($q->fetchAll(PDO::FETCH_ASSOC));
?>
=====
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);
$q->execute();
print_r($q->fetchAll(PDO::FETCH_ASSOC));
=====
Actual result:
--------------
See description.
--
Edit bug report at http://bugs.php.net/bug.php?id=53475&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53475&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53475&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53475&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=53475&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53475&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=53475&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=53475&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=53475&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=53475&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=53475&r=support
Expected behavior: http://bugs.php.net/fix.php?id=53475&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=53475&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=53475&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=53475&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53475&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53475&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=53475&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=53475&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=53475&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=53475&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=53475&r=mysqlcfg