Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Error with DB::count_last_query() in 1.8.0
grknight
April 2016
I have a query which ends with "ORDER BY LVL, LastName LIMIT 1, 100".
When I upgraded to 1.8.0, the new code in count_last_query() is not stripping out the ", LastName" and gives an invalid syntax SQL error
The regex in
https://github.com/fuel/core/commit/c8a045d7083800ef9b4b736cf433f07c76db7c5b
does not seem to work 100% of the time.
grknight
April 2016
Further testing..
"ORDER BY LVL ASC, LastName LIMIT 1, 100" - fails
"ORDER BY LVL, LastName ASC LIMIT 1, 100" - works
"ORDER BY LVL ASC, LastName ASC LIMIT 1, 100" - works
grknight
April 2016
Instead of trying to parse out the various ways, why not just do a replace to "ORDER BY NULL" as that cancels any sorting in a standard way. I'm pretty sure all the common databases support this.
Harro
April 2016
Created
https://github.com/fuel/core/issues/1990
Harro
April 2016
Could you try this one for me, and let me know if it works for you?
$sql = preg_replace("/ORDER BY (.+?)(?=LIMIT|GROUP|PROCEDURE|INTO|FOR|LOCK|\)|$)/mi", '', $sql);
We never thought about hand-coded queries when trying to come up with the regex.
Harro
April 2016
ping?
Any chance to have a look at it?
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
grknight
April 2016
Harro
April 2016