drbmhd9583
2016-02-09 11:30 阅读 38
已采纳

从另一个控制器codeigniter调用模型的方法

I am having two controllers hrcontroller and admincontroller.

And models hrmodel and adminmodel.

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    doucan1979 doucan1979 2016-02-09 11:52

    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.

    点赞 评论 复制链接分享
  • douliu1092 douliu1092 2019-03-27 09:36

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

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

    点赞 评论 复制链接分享

相关推荐