How to load a model from another module using CodeIgniter

Im using the HMVC extension with CodeIgniter and I have 2 modules

modules/frontpage
  -- controllers
    frontpage.php ( <- this controller needs to load the person model)
  -- models
  -- views
modules/person
  -- controllers
  -- models
    person_model.php ( defines Person_Model extends Model )
  -- views

using the $this->load->model('person_model')inside of the front panel controller, it seems that only global or models contained in one module (main page models) are loaded.

Are there any CodeIgniter experts here?

+3
source share
3 answers

Found it ... it was a simple fix.

Just needed to use: $this->load->model('person/person_model');

+13
source

from what I am experiencing in another version of codeigniter, the correct way to load the model is $ this-> load-> model ($ model = 'person', $ module = 'person');

0
$rand=rand(1,9999999);
$currentModel="currentModel".$rand;
$this->load->model($call_model,$currentModel);
$call_method=$method;            
$currentMod=$currentModel;
$CI =& get_instance();
$re_data= $CI->$currentMod->$call_method($paramArr);
0

Source: https://habr.com/ru/post/1752150/


All Articles