Welcome Guest, Not a member yet? Register   Sign In
How should one organise controllers and their functions?
#6

[eluser]mvdg27[/eluser]
Well, it's by no means necessary to use an extra model for CRUD operations. Just in my case (a CMS) I kept writing the same functionality over and over again. That should be the decision point for you: do you use the same functions in different models/ controllers?

My earlier example about storing the modification date and modifier was one of these tasks. Now it's automatically added everywhere. Now for example if I was to decide that I also want to store the IP of the person making the last modification, I wouldn't have to add this for every controller, but just in this one model.

Another function that I have in this 'general_model' is 'save_tree'. As almost all of my CMS modules are based on menustructures and they are all stored the same way, it was beneficial to use only one function for that, instead of copy-pasting it every time.

All in all, it depends if it makes sense for you to have a a 'general' model as well. In my situation it makes the code better to read and easier to maintain.

Michiel


Messages In This Thread
How should one organise controllers and their functions? - by El Forum - 01-12-2009, 03:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB