Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Naming Conventions for ORM Models
  • I'm curious as to how other people go about naming/placing their ORM models alongside their other Models.

    I've always placed ORM model files within an orm folder (model\orm\ormmodelname.php). This avoids having a 'People' ORM model and a 'People' model. 

    Is this something that other people do as well or is there another/better way to do this?
  • I only use one single model, I don't see the reason for having two. And I have them all in the \Model namespace (or in the \<module>\Model namespace).
  • So you have non-ORM logic in your ORM model? I haven't dug into the Core to see what the differences between extending an ORM model vs. a normal model are so I guess I always assumed it would have caused problems.
  • HarroHarro
    Accepted Answer
    Define "non-ORM" logic?

    For me, a model is the abstraction layer between my code and my data. So methods relating to retrieving, storing and processing data go in the model.

    So my controllers don't contain:


    they contain

    Model_Blah::get_this_data(limit, offset);

    How it gets the data, I couldn't care less (from a controller point of view). It also allows you to swap your ORM and/or DB store by something else, and your controller would be oblivious...

    As long as it's not too complex, there is no problem if you do that in the same model class. If it gets more complex, or if the methods are not directly related to a single model, I use separate model classes, which in turn use their underlying ORM models.

    See also my CICONF presentation:

  • I apologize for any confusion. By non-ORM models I am referring to Models that only extend Model ( 

    Thanks for your quick responses and insight :)
  • Ah, ok. In that case, I already answered that. ;-)

Howdy, Stranger!

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

In this Discussion