Reputation: 635
I have a doubt with the implementation of the model and can not find a reasonable explanation for the problem. I'll give you an example I'm working, it is an MVC implementing a blog.
I am ControllerPost which is responsible for control of reading a particular post Blog consequently have the ModelPost
the ModelPost must contain all methods needed?
method getPost()
method getComment()
method getArchive()
or should I isolate the methods?
ModelPost
method getPost()
ModelComment
method getComment()
ModelArchive
method getArchive()
this causes me much confusion, I see examples but no proper explanation. I hope that was clear in my doubts, otherwise try to be more explanatory
Thank all
Upvotes: 1
Views: 226
Reputation: 1881
In most projects I've worked on, we've had a model class for a database table. Using mostly Zend MVC, that would mean extending the Zend_Db_Table classes for each entity. So in your case, if the comment, post and archive are different tables (which I suppose they are), I'd build separate classes with get, update, insert and delete (and other similar) methods.
This might steer a bit off topic, but I suggest you look into domain driven development (DDD): There are links to some good reading material here: Domain-driven design with Zend
Also give this a read:
The main thing about the DDD is that it switches your mindset from thinking about database tables, more towards thinking about the main logical parts of your application, and then slowly adding a persistence layer below it and the application and service layers above it.
Upvotes: 2