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.
Orm
order_by related model's field first
yoshin
November 2012
Hi all,
How can I specify the order of 'order by' conditions including related fields?
Here is my code:
$results = Model_Article::query()
->related('author')
->order_by(
array(
'author.name'=>'ASC',
'category_id'=>'ASC',
)
)
->get();
I want to sort by author name first and then category_id. But the above code results the SQL like:
"
ORDER BY `t0`.`category_id` ASC, `t1`.`name` ASC".
Is there any way to make the related table's field come before the main table's?
Harro
November 2012
What version of FuelPHP are you on?
This issue was reported (
https://github.com/fuel/orm/issues/134
) and fixed about 2 months ago.
yoshin
November 2012
You're right! Mine was 1.2. I should have checked on the latest version first.
Thanks!
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,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
November 2012
yoshin
November 2012