#32736 [NEW]: Select table.field returns wrong result index
| From: | bart at mediawave dot nl | Date: | Sun, 17 Apr 2005 10:23:05 +0000 |
| Subject: | #32736 [NEW]: Select table.field returns wrong result index | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-77675@lists.php.net to get a copy of this message | ||
From: bart at mediawave dot nl
Operating system: WinXP
PHP version: 5.0.4
PHP Bug Type: SQLite related
Bug description: Select table.field returns wrong result index
Description:
------------
With the SQLite functions:
The problem occurs when selecting fields in a tablename.fieldname manner.
Example:
SELECT test.myfield, test.otherfield FROM test
The result array will have ['tablename.fieldname'] as index. This should
be just ['fieldname'] as index.
Reproduce code:
---------------
<?php
$dbfile = 'db/test2db.db';
if (!file_exists($dbfile)) {
$setup = "
CREATE TABLE test (myfield varchar(50), otherfield varchar(50));
INSERT INTO test (myfield, otherfield) VALUES ('value1', 'value1');
INSERT INTO test (myfield, otherfield) VALUES ('value2', 'value2');
";
}
$connectionId = sqlite_open($dbfile, 0666, $sqliteerror);
if ($setup)
sqlite_exec($connectionId, $setup);
$sql = 'SELECT test.myfield, test.otherfield FROM test';
$resultId = sqlite_query($connectionId, $sql);
while ($result = sqlite_fetch_array($resultId, SQLITE_ASSOC))
print_r($result);
?>
Expected result:
----------------
Array
(
[myfield] => value1
[otherfield] => value1
)
Array
(
[myfield] => value2
[otherfield] => value2
)
Actual result:
--------------
Array
(
[test.myfield] => value1
[test.otherfield] => value1
)
Array
(
[test.myfield] => value2
[test.otherfield] => value2
)
--
Edit bug report at http://bugs.php.net/?id=32736&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32736&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32736&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32736&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32736&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32736&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32736&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32736&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32736&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32736&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32736&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32736&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32736&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32736&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32736&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32736&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32736&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32736&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32736&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32736&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32736&r=mysqlcfg