在Codeigniter中扩展多个模型2 [英] Extending Multiple models in Codeigniter 2

查看:214
本文介绍了在Codeigniter中扩展多个模型2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置CI2以允许扩展多个模型?

How do you set up CI2 to allow extending of multiple models?

我只能得到它扩展一个模型(放在/ application / core) strong> MY_Model (区分大小写)。

I can only get it to extend one model (put in /application/core) named MY_Model (case sensitive).

选择要扩展的模型
在模型中。

To choose what model to extend I am doing; in the model..

require_once APPPATH.'core/MY_Another_model.php';
class Test_model extends MY_Another_model {
...
}

我不能在核心系统代码中找到在哪里它只能允许正在扩展的模型被称为MY_Model。

I can't find where in the core system code where it states only to allow models that are being extended to be called MY_Model.

感谢您的任何和所有帮助。

Thank you for any and all help.

推荐答案

,你只是把两个类放在同一个MY_Model文件中。此文件用作codeigniter的自动加载功能的一部分,这意味着它将查找具有MY_(或config defined)前缀的任何文件。

As I said in this question about the controllers you just put both classes in the same MY_Model file. This file is used as part of the autoload feature of codeigniter, meaning that it will look for any files with the MY_ (or config defined) prefix.

甚至需要调用MY_Model里面的类,你可以调用它MY_Special_Model,并在下面有MY_Another_Model

You don't even need to call the class inside MY_Model you can potentially call it MY_Special_Model and have MY_Another_Model directly underneath

这篇关于在Codeigniter中扩展多个模型2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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