0

I am having two controllers hrcontroller and admincontroller.

And models hrmodel and adminmodel.

It is possible to access a method in hrmodel from admincontroller. ?

David
  • 1,147
  • 4
  • 17
  • 29
Kannan Sivam
  • 29
  • 1
  • 6
  • similar question http://stackoverflow.com/questions/14165895/how-to-load-a-controller-from-another-controller-in-codeigniter – Dezigo Feb 09 '16 at 11:34

3 Answers3

1

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.

David
  • 1,147
  • 4
  • 17
  • 29
0

This answer did not work for me. Heres what worked out for me:

$this->load->model('hrcontroller/hrmodel'); $this->hrmodel->myfunction();

Rashmy
  • 125
  • 8
0

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.
}