I have many models, let’s say “Model1”, “Model2” and “Model3”. I have a certain group of actions that usually calls a method from each of these models and executes them in order:
$user_info = $this->load->User_model->load( $user_id );
$this->load->Car_model->deleteCarsForUser( $user_info );
$this->load->Message_model->sendMessage( "Car deleted", $user_info );
That’s a crude sample, no doubt. But these three steps are called in several places by several controller methods. Is there anyway for me to encapsulate them into one statement somehow?
You could make a library to handle it and other related functions.
http://ellislab.com/codeigniter/user_guide/general/creating_libraries.html