php.net |  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
Votes:2
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
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.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at mengelke dot de
New email:
PHP Version: OS:

 

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


Test script:
---------------
<?php

  $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;"))
    var_dump($array);
   else
    die(sqlite_error_string(sqlite_last_error($conn)));
  }
  else
   die("Database $db not found!\n"); 
?>


Expected result:
----------------
array(1) {
  [0]=>
  array(2) {
    [0]=>
    string(6) "foobar"
    ["test"]=>
    string(6) "foobar"
  }
}

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-02 17:59 UTC] felipe@php.net
-Status: Open +Status: Feedback
 [2012-11-02 17:59 UTC] felipe@php.net
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.

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

DOES NOT WORK:
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC