模型类很简单基本是用了Controller的方法
直接代码:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class CI_Model {
function __construct()
{
log_message('debug', "Model Class Initialized");
}
// Model中使用core class的话是这样实现的
// 其实不如让 Controller Model 都继承一个Base类 所有实例化的core class 绑到这个基础类
function __get($key)
{
$CI =& get_instance();
return $CI->$key;
}
}
Code Tips:
主要利用了__get 魔术方法 调用Controller 这个 Super Class
方便继承model的用户model调用核心类
(这个好短。。。)