Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error with DB::count_last_query() in 1.8.0
  • 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.
  • 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
  • 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.
  • 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.
  • ping?

    Any chance to have a look at it?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion