Quote:
Originally Posted by Tanax
Otherwise you wouldn't be able to access the database from the controllers.
|
Now why would you need access to the DB via the controller?
In my mind controllers should not do any form of business logic, all of that is handled via the model, just like views handle presentation logic, so therefore you shouldn't need to access the DB via the controller. Obviously there is a need for a certain amount of logic in controllers, as there is in the view layer (don't get me started on PHP template languages at this stage of the day PLEASE), but to have the controller layer bunged up with logic is just silly, you may as well just go back to the old skool way and have a php file per page.
Models are not synonymous with database. I quite often see code that is supposedly 'MVC' and all I can see in the model is a pointless 'ActiveRecord' (or similar) class with no logic in it and a controller littered with business logic.
Controllers are there to glue the model to the view, interpreting user input into the model and passing data back to the user via the view.
fat model and a thin controller is all you need to remember.
I'll stop myself there as we are wandering dangerously close to the 'off topic' mark and I will being ranting before long.
Now where did I put my coffee?