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
Order by relation
ThAlmighty
July 2013
Is there a way to order by a relations property? For example: Model Posts has many Comments. When I query Posts from the Model internally, can i say it will need to order by the Comments.created at?
ThAlmighty
July 2013
Never mind, I am totally stupid. You can use the related option in you options.
However, I have a following problem:
I have declared conditions in the Comments model. When using the related option in the Posts model, it throws an error:
Fuel\Core\PhpErrorException [ Notice ]: Undefined offset: 2
it has to do with
PKGPATH/orm/classes/hasmany.php @ line 112
is_string
(
$condition
[
2
]) and
$condition
[
2
] = \
Db
::
quote
(
$condition
[
2
],
$model
[
'connection'
]);
Can anybody explain my how to properly use both contiditions on related Models and using the related option in a parent class?
ThAlmighty
July 2013
Never mind again, it was a type error in the condition array. I declared it like this:
array('object_type', 5);
Which should have been:
array('object_type', '=', '5');
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
ThAlmighty
July 2013