How should this function be achieved using MVC

#11
[eluser]pawz[/eluser]
It seems to me that there's at least three possible locations for your general purpose functions:

1. private functions in the controller
2. functions in a library
3. functions in a model

I thought that more people would recommend option 1, as I've seen code that works like this, but so far this seems unpopular.
Option 2 is what I've been doing currently but it's a little messy because it requires the use of get_instance to get the codeigniter object.
Option 3 is one I hadn't really considered, but the comments so far make it sound more attractive. This involves using the model for general processing functions instead of just database functions which is something I hadn't considered.

After the posts here so far, I'm leaning towards option 3. Comments appreciated

#12
[eluser]wiredesignz[/eluser]
Controllers are for processing user input, security and deciding which Views to display. They are not supposed to be used to query the database or any other application related logic.

Private functions in controllers to process data are inherently flawed, particularly if another controller needs the same data processing facilty.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.