Welcome Guest, Not a member yet? Register   Sign In
Best place to put callback functions CodeIgniter - Grocery Crud
#1

Hello,

I'm new to CodeIgniter and I am in doubt about where is the best place to put the callback functions: Controller or Model?

I'm using Grocery Crud to perform some of the crud actions, and it has it's own callback functions as well. Where is the best place to place these? Grocery crud is used on controller. The example bellow shows my doubt:

Code:
//I can call the model class and place the actual 'callback_after_insert' function there:
$this->grocery_crud->callback_after_insert(array($this->Admins_model, 'callback_after_insert'));

//Or, I can place the callback function in the controller class and just call it like this:
$this->grocery_crud->callback_after_insert(array($this, 'callback_after_insert'));

Which one is the best practice?

Thanks a lot!
Reply
#2

If your dealing with database stuff then put it in your model.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(07-09-2015, 03:06 PM)InsiteFX Wrote: If your dealing with database stuff then put it in your model.

Thank you!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB