Example #1
0
 /**
  * 动态获得model 以便于不用显式加载model
  * $key对应相应的Model类
  *
  * @example
  * $this->__task表示获得是应用级的model
  * $this->_task表示模块级的model
  *
  * @param string $key
  */
 public function __get($key)
 {
     if ('__' == substr($key, 0, 2)) {
         $model = substr($key, 2);
         return $this->loadAppModel($model);
     } else {
         $prefix = substr($key, 0, 1);
         if ('_' == $prefix) {
             $model = substr($key, 1);
             return $this->loadModel($model);
         } else {
             return parent::__get($key);
         }
     }
 }