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
ORM WHERE LIMIT inside the Subquery
willoller
July 2014
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?
Harro
July 2014
You may want to use rows_limit() instead of limit().
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
Harro
July 2014