Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Related datas and find lazy
  • Hello guys !

    Is there any way to do a Model_thing::find($id) not lazy without "related" ? Or something like Model_thing::find($id,array('related' => "all") ? Because I've like .... 10 relations for one model and to set every related every time is really .... 
    I have to do this because the ORM can only break relations if it knows they exist.(Thanks to Harro Verton for his answer) 

    I'm using Fuel 1.5.2

    Thanks
  • HarroHarro
    Accepted Answer
    No.

    But nobody is stopping you from adding a findall() static method to your model which returns the result of a static::find($id, array('with all our relations'));. That way you only have to code it once and you can use it everywhere.

    It is a common misconception that if you use an ORM, you should only use the provided methods and do the rest in your controllers.The rules and best practices for using models are still valid: abstract all data manipulation away in your model. So even with ORM, add a "find_users" method to your model, instead of doing Model_Users:find() in your Controller.
  • In fact, adding a static method was my second solution ! I did it before my question.
    It was just to know if there are any native solution. 

    Thanks Haro

Howdy, Stranger!

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

In this Discussion