Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM WHERE LIMIT inside the Subquery
  • I am using the ORM and am having a problem applying my WHERE clause to the correct place in the query:

    Model_Thing::find()->where('a','=','a')->limit(50)->related('child');

    produces a query similar to:

    SELECT * FROM (SELECT * FROM things t0 LIMIT 50) as t0 JOIN child ON ... WHERE `t0`.`a` = "a";

    but this does not search the entire table for a=a and return 50, instead it gets 50 and filters those where a=a.

    What I need is 

    SELECT * FROM (SELECT * FROM things t0 WHERE `t0`.`a` = "a" LIMIT 50) as t0 JOIN child ON ... ;


    Is putting the WHERE inside the subquery something that can be done with ORM? Or am I going to have to go back to writing my own SQL?
  • You may want to use rows_limit() instead of limit().

Howdy, Stranger!

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

In this Discussion