Bug #69474 [NEW]: ODBC: Query with same field name from two tables returns incorrect result

From: Date: Fri, 17 Apr 2015 10:05:21 +0000
Subject: Bug #69474 [NEW]: ODBC: Query with same field name from two tables returns incorrect result
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192147@lists.php.net to get a copy of this message
From: heinrich dot moser dot jun at moware dot at Operating system: Windows Server 2012 R2 PHP version: 5.5.24 Package: PDO ODBC Bug Type: Bug Bug description:ODBC: Query with same field name from two tables returns incorrect result Description: ------------ An ODBC query which created a correct result with PHP 5.5.23 produces an incorrect result with PHP 5.5.24. Tested on Windows Server 2012 R2 with SQL Server 2012. How to reproduce: 1. Create an empty database and create the table with the test script given. 2. Create a system DSN called "forum" which connects to the database. 3. Execute the test script given with PHP 5.5.23 and 5.5.24 and compare the results. Test script: --------------- Database: CREATE TABLE table1 (topic_id int); CREATE TABLE table2 (topic_id int); INSERT INTO table1 (topic_id) VALUES (1023); Code: <?php date_default_timezone_set('Europe/Vienna'); $link = odbc_connect("forum", "", ""); $sql = "SELECT table1.topic_id, table2.topic_id AS X FROM table1 LEFT JOIN table2 ON table1.topic_id = table2.topic_id WHERE table1.topic_id = 1023"; $result = odbc_exec($link, $sql); $topic_data = odbc_fetch_array($result); var_dump($topic_data); odbc_free_result($result); odbc_close($link); ?> Expected result: ---------------- This is the script output I get with PHP 5.5.23: array(2) { ["topic_id"]=> string(4) "1023" ["X"]=> NULL } Actual result: -------------- This is the script output I get with PHP 5.5.24: array(1) { ["topic_id"]=> NULL } -- Edit bug report at https://bugs.php.net/bug.php?id=69474&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69474&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69474&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69474&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69474&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69474&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69474&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69474&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69474&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69474&r=support Expected behavior: https://bugs.php.net/fix.php?id=69474&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69474&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69474&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69474&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69474&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69474&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69474&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69474&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69474&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69474&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69474&r=mysqlcfg

« previous php.bugs (#192147) next »