When it comes to the controller/model discussion, there are basically two camps:
- fat controller / lean model
In this scenario the model doesn’t do much more then some basis I/O (get, insert. update), all other logic, like query building, data selection and conversion, validation, is done in the controller
- lean controller / fat model
The opposite of the above. Controllers don’t do much more then controlling the flow from request to response, fetching model info and passing it on to a view. The model contains functional logic, such as get_active_clients(), which not only builds the query and the selection, but also returns the data in a unified format directly suitable for the view. In case of inserts or updates, the model also does the validation of the input, to ensure all data in the database is correct.
I am a supporter/user of the last scenario. It is more DRY in that no matter where the data comes from or who requests it, there is only one piece of code (the method in the model) responsible for it. It also hides the datamodel from your controllers. as long as your model methods return what they should, it doesn’t matter if the data comes from one or ten tables, or perhaps a REST service. Your controller doesn’t care, and doesn’t need to be changed when your data model changes.