PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #7274

SQL query ORDER BY error in fetchRow method

Details

Submitted2006-04-01 16:24 UTC
Fromoganovic at gmail dot com
StatusBogus
PackageDB
PHP Version4.3.1
OSLinux
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);