From: andrew at howsfamily dot net Operating system: Windows XP Pro PHP version: 4.3.2 PHP Bug Type: ODBC related Bug description: ORDER BY clause not sorting results
Description: ------------ When running a query, the ORDER BY clause seems to be ignored. ODBC is connecting to MS Access via the standard MS driver. When the query is run in a MS Access query, it sorts correctly. When the resultset is returned via the PHP ODBC functions, however, the rows are returned in the order they were created, not the order specified by the ORDER BY clause. Reproduce code: --------------- SELECT Person.Surname, Person.[Given Name(s)], Owing - IIF(Payments.Total IS NULL, '0', Payments.Total) AS Amount FROM Person, Registration, (SELECT Registration.Surname, Registration.[Given Name(s)], SUM(Amount) AS Total FROM Registration LEFT OUTER JOIN Receipt ON (Registration.Camp = Receipt.Camp) AND (Registration.Surname = Receipt.Surname) AND (Registration.[Given Name(s)] = Receipt.[Given Name(s)]) WHERE Registration.Camp='Summer Camp 2003' GROUP BY Registration.Surname, Registration.[Given Name(s)], Registration.Owing) AS Payments WHERE Person.[Given Name(s)] = Registration.[Given Name(s)] AND Person.Surname = Registration.Surname AND Person.[Given Name(s)] = Payments.[Given Name(s)] AND Person.Surname = Payments.Surname AND Camp = 'Summer Camp 2003' AND (Owing - IIF(Payments.Total IS NULL, '0', Payments.Total)) > 0 AND Person.[Given Name(s)] = Registration.[Given Name(s)] AND Person.Surname = Registration.Surname ORDER BY Person.Surname Expected result: ---------------- SURNAME GIVEN NAME(S) AMOUNT ------------------------------------------- Aardvark Fred $130.00 Badger Bob $150.00 Dalmation Jim $150.00 Actual result: -------------- SURNAME GIVEN NAME(S) AMOUNT ------------------------------------------- Aardvark Fred $130.00 Dalmation Jim $150.00 Badger Bob $150.00 -- Edit bug report at http://bugs.php.net/?id=26479&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26479&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26479&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26479&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26479&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26479&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26479&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26479&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26479&r=support Expected behavior: http://bugs.php.net/fix.php?id=26479&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26479&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26479&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26479&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26479&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26479&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26479&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26479&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26479&r=float