Home » Database » DB » Bug #7274
SQL query ORDER BY error in fetchRow method
Details
| Submitted | 2006-04-01 16:24 UTC |
|---|---|
| From | oganovic at gmail dot com |
| Status | Bogus |
| Package | DB |
| PHP Version | 4.3.1 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-04-01 16:24 UTC] oganovic at gmail dot com
Description:
------------
If you order a query with a single field like this:
"SELECT * FROM dataset WHERE (field3='" . trim($arg) ."')
ORDER BY (field1);"; and use this in a tipical
$row = $result->fetchRow(DB_FETCHMODE_ASSOC) it works... but if you try to order it with ORDER BY (field1,field2) it just crashes. So it works only if you put it without brackets:
"SELECT * FROM dataset WHERE (field3='" . trim($arg) ."')
ORDER BY field1,field2;";
Test script:
---------------
//with a valid $db object
$sql="SELECT * FROM dataset WHERE (field3='" . trim($arg) ."')
ORDER BY (field1,field2);";
$result = $db->query($sql);
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);