CodeIgniter中的常用功能 [英] Common functions in CodeIgniter

查看:56
本文介绍了CodeIgniter中的常用功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CodeIgniter的新手。

I am new to CodeIgniter.

我在CodeIgniter中使用HMVC,并希望在许多其他模块中使用模块功能:

I am using HMVC in CodeIgniter and want to use a module function in many other modules:

例如,我有一个具有get_locations($ param)函数的Locaton_model {return; }

e.g I have a Locaton_model with function get_locations($param) { return; }

如何在许多其他模块中使用上述功能?每次需要此功能时,是否应该在其他模块控制器中加载模型,还是应该在全局位置将该功能定义在其他地方?

How do I use the above function in many other modules? Should I load the model in other module controllers every time I need this function or define the function some where globally?

推荐答案

首先创建自己的模型,然后确保它位于核心文件夹中,然后在控制器上扩展该模型名称

if your creating your own model first make sure it is inside the core folder second on your controller extends the model name like this

class myController扩展Locaton_model
{

function index()
{
$this->load->model->("your model name");
$this->yourmodelname->functionname($param);
}

}

这篇关于CodeIgniter中的常用功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆