Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
ORM + relations + order_by?
  • Hi! When using relations I can grab all the comments for lets say a Blog post by doing
    $post = Model_Post::find($id);
    $comments = $post->comments;
    
    // do something with the comments...
    

    Given there are comments to the post it will return an array of Comment objects. Is there any way to do an order_by using the ORM or do I have to go through the query builder to do this?
  • Take a look at the examples in the docs: http://fuelphp.com/docs/packages/orm/crud.html#read It's only supported for eager loading, lazy loading as in your example just grabs the relation without additional conditions.
  • Yup I got it to work, the query chaining can be quite confusing when you want to do alot of stuff :)
    Thanks!

Howdy, Stranger!

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

In this Discussion