七行笔记

导航

十二)CodeIgniter源码分析之Model.php

 1 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 2 /**
 3  * CodeIgniter Model Class
 4  */
 5 class CI_Model {
 6 
 7  /**
 8   * Constructor
 9   */
10  function __construct()
11  {
12   log_message('debug', "Model Class Initialized");
13  }
14 
15  /**
16   * __get
17   * Model类的代码也非常少,有用的方法就下面这一个,下面这个方法是为了在Model里面可以像控制器那么通过$this->
18   * 做很多事情。例如想在model里面加载某个library,就可以$this->load->library(xxx),其实它都是盗用controller的。
19   */
20  function __get($key)
21  {
22   $CI =& get_instance();
23   return $CI->$key;
24  }
25 }

 

posted on 2015-04-10 17:24  七行笔记  阅读(170)  评论(0编辑  收藏  举报