Home » Database » DB » Bug #3666
getOne/getRow optimization causes query error
Details
| Submitted | 2005-03-02 09:55 UTC |
|---|---|
| From | t dot fritsche at webmasterorder dot de |
| Assigned | danielc |
| Status | Closed |
| Package | DB |
| PHP Version | Irrelevant |
| 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]