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 #3666

getOne/getRow optimization causes query error

Details

Submitted2005-03-02 09:55 UTC
Fromt dot fritsche at webmasterorder dot de
Assigneddanielc
StatusClosed
PackageDB
PHP VersionIrrelevant
Roadmaps(Not assigned)

Comments

[2005-03-02 09:55 UTC] t dot fritsche at webmasterorder dot de

Description:
------------
The optimization changes made to the getOne and getRow simply append the string
LIMIT ... to the query.

If someone has queries where getOne/getRow was used and there is a semicolon at the end of the query. These queries will result in a SQL Syntax error, because the "LIMIT 0,1" will be appended after the semicolon.

Reproduce code:
---------------
$result = $db->getOne("SELECT col FROM table;");
if (DB::isError($result)) {
$result->getDebugInfo();
} else {
echo $result;
}

Expected result:
----------------
The first column returned from table.

Actual result:
--------------
[nativecode=1064 ** You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ';
LIMIT 0, 1' at line 8]