|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62878 Problems with Subqueries in SQLite2
Submitted: 2012-08-21 14:48 UTC Modified: 2013-02-18 00:35 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: php at mengelke dot de Assigned:
Status: No Feedback Package: SQLite (PECL)
PHP Version: 5.3.16 OS: Windows XP SP3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-08-21 14:48 UTC] php at mengelke dot de
Since the update of php5.3.10 on php5.3.16 simple subqueries work with "WHERE" no more!

Test script:

  $db = ".test.sdb";

  if(!function_exists('sqlite_open') and !dl('php_sqlite.dll'))
   die("SQLite-Extension Failed!\n");
  elseif($conn = sqlite_open($db)) {
   @sqlite_exec($conn,"CREATE TABLE [test] ([id] INTEGER NOT NULL PRIMARY KEY, [char] VARCHAR(255) NULL); INSERT INTO test (id,char) VALUES (1,'foobar');");	// Create Test-Table
   if($array = sqlite_array_query($conn,"SELECT test FROM (SELECT id,char AS test FROM [test]) WHERE id = 1;"))
   die("Database $db not found!\n"); 

Expected result:
array(1) {
  array(2) {
    string(6) "foobar"
    string(6) "foobar"

Actual result:
Warning: sqlite_array_query(): near ";": syntax error in sqlite.php on line 9 SQL logic error or missing database


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-02 17:59 UTC]
-Status: Open +Status: Feedback
 [2012-11-02 17:59 UTC]
Try removing ';' from the query.
 [2012-11-11 11:21 UTC] php at msvplus dot de
I have a similar or the same problem on a customer's Mac. Most SQLite2-queries in the application work without any problems but a specific one gives the warning message:
"sqlite_array_query(): near ";": syntax error in /Users/x/Sites/y/z.php on line 20"

This query contains a complex sub-query.
The very same query DOES work on PHP Version 5.3.10 (OS X 10.7 / Lion) but it doesn't on PHP Version 5.3.15 (OS X 10.6.8 / Snow Leopard). It also works on my own machines (Linux, 
Windows) using PHP 5.2.x.

Removing the ";" from the query does not help.

OS X 10.7 / Lion
PHP Version 5.3.10 
SQLite Library Version 2.8.17
SQLite Encoding: UTF-8

OS X 10.6.8 / Snow Leopard
PHP Version 5.3.15
SQLite Library Version 2.8.17
SQLite Encoding: iso8859
 [2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Oct 02 12:01:25 2023 UTC