Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #3666 getOne/getRow optimization causes query error
Submitted: 2005-03-02 09:55 UTC
From: t dot fritsche at webmasterorder dot de Assigned: danielc
Status: Closed Package: DB
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [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]

Comments

 [2005-03-02 14:31 UTC] danielc
The standard practice in PHP's DBMS extensions is to not require, and in fact usually reject, queries with ";" appended to them. FrontBase is the only DBMS extension in PHP where one is supposed to append ";". So, the number of users already placing ";"'s on their queries is small enough to nearly make this bug a non-issue. None the less, I'll address it in the next release, though I make no promises as to when that will come out.
 [2005-03-02 14:44 UTC] danielc
Fixed in CVS.
 [2005-03-04 23:24 UTC] danielc
The modifyLimitQuery() optimizations for getOne() and getRow() have been removed from DB as of release 1.7.3 due to backwards compatibility issues.