Пример #1
0
 /**
  * 获取配置文件中的数据信息
  *
  * @param $fileName
  *
  * @return mixed
  */
 private static function getFileData($fileName)
 {
     $langFilePath = APP_LANG_PATH . '/' . $fileName;
     file_exists($langFilePath) or Halt('Lang 目录中无 ' . $fileName . ' 文件');
     return include $langFilePath;
 }
Пример #2
0
 /**
  * 执行对数据库的增删改查操作命令
  *
  * @param string $sql
  *
  * @return array|int
  */
 public static function select($sql = '')
 {
     $result = mysqli_query(self::$link, $sql);
     $result or Halt('数据库操作失败:' . mysqli_error(self::$link));
     $data = array();
     if (is_bool($result)) {
         return mysqli_affected_rows(self::$link);
     }
     while ($row = mysqli_fetch_assoc($result)) {
         $data[] = $row;
     }
     return $data;
 }
Пример #3
0
 /**
  * 模版缓存
  *
  * @param null $tpl
  * @return false|string
  */
 protected function isCached($tpl = null)
 {
     C('CACHE_START') or Halt('请先开启模版缓存');
     $path = $this->setTemplatePath($tpl);
     return self::$smarty->is_cached($path, $_SERVER['REQUEST_URI']);
 }
Пример #4
0
 /**
  * 自动加载类
  *
  * @param $className
  */
 private static function autoload($className)
 {
     // 获取要访问的项目类文件扩展名
     $extension = C('CLASS_FILE_EXTENSION_NAME');
     switch ($className) {
         //  加载控制器类
         case 'Controller' == substr($className, -10):
             $path = APP_CONTROLLERS_PATH . "/{$className}{$extension}";
             if (!file_exists($path)) {
                 $emptyFile = APP_CONTROLLERS_PATH . '/' . C('URL_ERROR_CONTROLLER') . C('CLASS_FILE_EXTENSION_NAME');
                 file_exists($emptyFile) or Halt($className . ' 控制器未找到');
                 include $emptyFile;
                 return;
             }
             include $path;
             break;
             // 加载模型类
         // 加载模型类
         case 'Model' == substr($className, -5) && strlen($className) > 5:
             $path = APP_MODELS_PATH . "/{$className}.php";
             if (!file_exists($path)) {
                 $path = COMMON_MODEL_PATH . "/{$className}.php";
             }
             file_exists($path) or Halt($className . ' Model未找到');
             include $path;
             break;
             // 默认加载框架扩展工具类
         // 默认加载框架扩展工具类
         default:
             $path = EXTEND_TOOL_PATH . "/{$className}.php";
             file_exists($path) or Halt($className . ' 类文件未找到');
             include $path;
     }
 }
Пример #5
0
 /**
  * 处理访问不存在的方法
  *
  * @param $method
  * @param $args
  */
 public function __call($method, $args)
 {
     $defaultMethod = C('URL_ERROR_METHOD');
     if (method_exists($this, $defaultMethod)) {
         $this->{$defaultMethod}();
         return;
     }
     Halt($method . ' 方法不存在');
 }