开发者

How to load a model from another module with CodeIgniter

Im using the HMVC extension with CodeIgniter and i got 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 )
  -- vi开发者_Python百科ews

using $this->load->model('person_model') inside frontpage controller seems to load only global or models contained in the same module (frontpage models).

Any CodeIgniter experts here?


Found it... it was a simple fix.

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


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


$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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜