Is this a good way to structure model on an MVC application?

karminezr0x

New Member
This is more a "Am i doing it right?" question.I am using a MVC framework ( Zend Framework ) and was wondering if this is the best way to structure a model.In this case i have an user groups model and, after coding for sometime, i realized that on my controllers i was repeating some stuff like a query to return visible groups.$model->fetchAll( array( 'enabled = 1', 'visible = 1') );In order to reduce code repetition, i created a method on this model that returns the query for visible groups.Based on this same situation, i also created many other methods like hidden groups, disabled groups etc.Is this the best way to avoid code duplication? My concern is that if i kept inserting that code on controllers i would have a big headache if the business rule for visible group changes in the future.At the same time i am also concerned that, if i follow this new approach, i will end up with a bloated model full of methods to return queries.How do you deal with this kind of situation?Thanks for your help!
 
Back
Top