php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27547 Sqlite column names change, but PRAGMA short_column_names=ON not working
Submitted: 2004-03-10 07:51 UTC Modified: 2004-03-10 09:23 UTC
From: col at mportal dot hu Assigned:
Status: Not a bug Package: SQLite related
PHP Version: 4.3.4 OS: linux, windows
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: col at mportal dot hu
New email:
PHP Version: OS:

 

 [2004-03-10 07:51 UTC] col at mportal dot hu
Description:
------------
In sqlite then return of the column names changed in new versions (aktual: 2.8.13)
The return type (short name or long name) can be set with: PRAGMA short_column_names=ON; It works fine from sqlite console, but not from php. And php has no any ini setting, to change this variable. Setting this from query before select query, has no affect.

Reproduce code:
---------------
$db = sqlite_open('mydb.db',0666, $sqliteerror);
sqlite_query($db,"create table t1(id1 int,n1 varchar(5)");
sqlite_query($db,"create table t2(id2 int,n2 varchar(5)");
sqlite_query($db,"insert into t1(id1,n1) values (1,'N1')");
sqlite_query($db,"insert into t2(id2,n2) values (1,'N2')");
sqlite_query($db, 'PRAGMA short_column_names=ON');
/**
select *, or select t1.id1, t2.id2, t1.n1, t2.n2, or select t1.*, t2.* is the same effect
*/
$result=sqlite_query($db,'select * from t1,t2 where t1.id=t2.id');
echo "<pre>",var_dump(sqlite_fetch_array($result,SQLITE_ASSOC)),"<pre>";


Expected result:
----------------
array(4) {
  ["id1"]=>
  string(1) "1"
  ["n1"]=>
  string(1) "N1"
  ["id2"]=>
  string(1) "1"
  ["n2"]=>
  string(2) "N2"
}

Actual result:
--------------
array(4) {
  ["t1.id1"]=>
  string(1) "1"
  ["t1.n1"]=>
  string(1) "N1"
  ["t2.id2"]=>
  string(1) "1"
  ["t2.n2"]=>
  string(2) "N2"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-10 09:08 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Bundled sqlite library is version 2.8.11, if you want to 
have latest features like "PRAGMA short_column_names" use 
external sqlite library. 
 [2004-03-10 09:23 UTC] col at mportal dot hu
Thanx, but this problem exists in bundled 2.8.11 too. I just found this pragma option workin in sqlite console, but not in php. The problem not the "PRAGMA short_column_names=ON". The problem is the name of returning columns, and the short_column_names option in sqlite which changed, and can not be set from php.

Probably a php.ini setting (or else, if it's not working from the query) could help this bug, in feature.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC