views:

201

answers:

1

Hello

I'm creating my own CMS and use doctrine for database.

Now I wonder, when I crate Post record, how much work should that record do?

An example:

I have Post -> Categories relation (one to many), should I create separate functions to append categories (to look if Post already has category, etc. ) or should Post do that using accessors / mutators?

What's the best practice?

+1  A: 

I think adding methods for the purprose you described is a good idea. Doctrine can sometimes be a bit tricky if you try to override the default actions that happen when accessing the properties.

In general, if there's anything that needs more than the default action, I would recommend having it as a method in the model class.

If you have a specific table with some table-specific actions, such as get every object by some rule, then it's a good idea to add a new method to the table-specific SomeTable class.

Since this is kind of like ActiveRecord, you would have the domain logic in the Doctrine record object.

Jani Hartikainen
Thank you for your answer, will think more that way.
usoban