Reputation: 47
I have 2 different model files with one common function.
So I written that function in another model file trying to access that by using:
$this->load->model('model_1');
$this->model_1->com_fun();
But it is not working. How can I call the functions of one model class inside another model class?
Upvotes: 0
Views: 869
Reputation: 151
Sometimes is useful to have in your controllers something like:
public function __construct(){
$this->CI =& get_instance();
}
So, when you need another model you can do:
$this->CI->load->model('another_codeigniter_model_name', 'another');
$something = $this->CI->another->com_fun();
Upvotes: 1