CI框架 -- 核心文件 之 Model.php

class CI_Model {

    /**
     * Class constructor
     *
     * @return    void
     */
    public function __construct()
    {
        log_message('info', 'Model Class Initialized');
    }

    // --------------------------------------------------------------------

    /**
     * __get magic
     *
     * Allows models to access CI's loaded classes using the same
     * syntax as controllers.
     *
     * @param    string    $key
     */
    public function __get($key)
    {
        // Debugging note:
        //    If you're here because you're getting an error message
        //    saying 'Undefined Property: system/core/Model.php', it's
        //    most likely a typo in your model code.
        return get_instance()->$key;
    }

}

所有的模型类都必须继承自CI_Model类

原文地址:https://www.cnblogs.com/hf8051/p/5160477.html