从另一个控制器codeigniter调用模型的方法(Calling a method of a model from another controller codeigniter)

编程入门 行业动态 更新时间:2024-10-18 01:29:07
从另一个控制器codeigniter调用模型的方法(Calling a method of a model from another controller codeigniter)

我有两个控制器hrcontroller和admincontroller 。

并模拟hrmodel和adminmodel 。

可以从admincontroller访问hrmodel的方法。 ?

I am having two controllers hrcontroller and admincontroller.

And models hrmodel and adminmodel.

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

最满意答案

在你的admincontroller你就是这么做的

$this->load->model('hrmodel'); $this->hrmodel->get_data(); //replace get_data for a real function on your model

你可以加载你想要的所有模型。

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.

更多推荐

本文发布于:2023-08-01 21:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1365798.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   模型   方法   codeigniter   controller

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!