将主模型扩展到不同目录中的子模型

时间:2012-07-27 23:49:17

标签: php codeigniter

我一直在寻找这个网站的答案,并找到了一些提出同样问题的人,但是我找不到一个真正说出正确解决方案的人。

我正在试图弄清楚如何让主模块保存某些变量值,以便我可以在其他模型中相应地访问它们。我正在我的计算机上的本地服务器上运行,我也在使用模块插件。我也是自动加载master_model。

问题是我收到一条错误消息,指出无法在users_model中找到master_model。

$autoload['model'] = array('msgboxes', 'metatags', 'genfunc', 'adverts', 'master_model');

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
* Master_model
*
* @author   Jeff Davidson
*/

class Master_model extends CI_Model 
{   
    function __construct()
    {
        parent::__construct();
    }

    var $users_table = 'users';
    var $user_profiles_table = 'user_profiles';
    var $user_login_sessions_table = 'user_login_sessions';
    var $user_statuses_table = 'user_statuses';
    var $user_roles_table = 'user_roles';

}

/* End of file master_model.php */
/* Location: ./application/models/master_model.php */

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
* Users
*
* This model represents user authentication data. It operates the following tables:
* - user account data,
* - user profiles
*
* @package  KOW Auth
* @author   Jeff Davidson
*/

class Users_model extends Master_model
{   
    function __construct()
    {
        parent::__construct();
    }


}

/* End of file users_model.php */
/* Location: ./application/modules/users/models/users_model.php */

1 个答案:

答案 0 :(得分:0)

您需要将Master_model放在application/core目录中,并将以下代码添加到application/config/config.php文件中:

function __autoload($class)
{
    if(strpos($class, 'CI_') !== 0)
    {
        @include_once( APPPATH . 'core/'. $class . EXT );
    }
}

了解更多here

相关问题