php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46803 Sqlite-PDO prepared statement doesn't return any rows when used with bind vars
Submitted: 2008-12-08 20:45 UTC Modified: 2008-12-19 01:00 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: scaligo at pt dot lu Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5.2.7 OS: Linux x86_64
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: scaligo at pt dot lu
New email:
PHP Version: OS:

 

 [2008-12-08 20:45 UTC] scaligo at pt dot lu
Description:
------------
A PDO prepared statement doesn't return any results for a given query performed with bind variables, but works fine when used without. A same value is used twice and the workaround for WONTFIX #33886 has been applied.

The initial query (with bind variables) returns the expected results in another environment (Ruby/SQLite3).

Reproduced on vanilla 5.2.7 and 5.3.0 alpha 3, x86_64.

Compile flags (5.2.7):
./configure \
--enable-debug \
--enable-cli \
--disable-cgi \
--disable-all \
--enable-pdo \
--with-pdo-sqlite \
--enable-sqlite-utf8


Reproduce code:
---------------
Test case:
http://nopaste.ch/855d0d151ef8216.html

Query:
SELECT u.login, c.code
FROM codes c, users u
WHERE u.id = c.user_id
AND substr(c.code, 1, min(length(c.code), :LEN1)) = substr(:CODE, 1, min(length(c.code), :LEN2))

Binds:
$statement->bindValue(':CODE', '111-222-', PDO::PARAM_STR);
$statement->bindValue(':LEN1', 8, PDO::PARAM_INT);
$statement->bindValue(':LEN2', 8, PDO::PARAM_INT);


Expected result:
----------------
The query should find the same rows with and without using bind variables.

Actual result:
--------------
The query returns no rows when used with bind variables and two rows without. No errors are reported by errorInfo().

The query behaved correctly when only binding :CODE and replacing :LEN1 and :LEN2 by their actual value.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-11 09:59 UTC] nasubi at pako dot ne dot jp
pdo_mysql has same problem on php-5.2.8 (x86_64)
 [2008-12-11 11:26 UTC] scottmac@php.net
I can't reproduce this on 5.3.0 alpha 3, works fine both times. It does however happen in 5.2. I was using regular x86 though.

Are you sure this happened with 5.3?
 [2008-12-11 14:03 UTC] scaligo at pt dot lu
I re-ran some tests:

It indeed works in 5.3.0 alpha3 if I bind :LEN1 and :LEN2 as PDO::PARAM_INT, but not as PDO::PARAM_STR. Using :LEN twice actually works too.

Is it possible to back-port the 5.3.0 changes to 5.2.x?
 [2008-12-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 10:01:38 2025 UTC