Reputation: 29
I am having two controllers hrcontroller
and admincontroller
.
And models hrmodel
and adminmodel
.
It is possible to access a method in hrmodel
from admincontroller
. ?
Upvotes: 0
Views: 742
Reputation: 1
The right way to do this with CI is the following:
From your Controller do this:
$this->hrmodel->my_function('in case you wanna pass an argument, place it here.');
And on your Model do this:
function my_function('in case youre passing an argument.'){
//Your functions behavior.
}
Upvotes: 0
Reputation: 125
This answer did not work for me. Heres what worked out for me:
$this->load->model('hrcontroller/hrmodel'); $this->hrmodel->myfunction();
Upvotes: 0
Reputation: 1145
in your admincontroller
you just do this
$this->load->model('hrmodel');
$this->hrmodel->get_data();
//replace get_data for a real function on your model
you can load all models you want doing this.
Upvotes: 1