Пример #1
0
 /**
  * 创建模型
  * @param string 要使用的数据库配置
  * @return void
  */
 public function __construct($key = 'mysql')
 {
     // 读取配置
     $driver = \Core\C::G($key);
     // 创建数据库
     $this->db = Mysql::instance($driver);
 }
Пример #2
0
 /**
  * 构造函数
  * @param string 模板目录
  * @param string 缓存目录
  * @param string 插件目录
  * @param int 过期时间
  * @param boolean 真缓存
  */
 public function __construct()
 {
     // 获取配置
     $view = C::view();
     // 模版文件
     $this->templateDir = VIEW . trim($view->theme) . "/";
     // 编译文件
     $this->compileDir = COMPILE;
     // 缓存文件
     $this->cacheDir = CACHE;
     // 插件文件
     $this->pluginDir = PLUGIN . "/View/";
     // 视图过期时间
     $this->expire = $view->expire;
     // 是否真缓存
     $this->cache = $view->cache;
 }
Пример #3
0
 public function testCallStatic()
 {
     $this->assertObjectHasAttribute('class', C::routes(), '从routes配置找不到class属性');
     $this->assertObjectHasAttribute('function', C::routes(), '从routes配置找不到function属性');
     $this->assertObjectHasAttribute('suffix', C::routes(), '从routes配置找不到suffix属性');
 }
Пример #4
0
define('COMPILE', DATA . 'Compile/');
// 模版编译文件
define('FONT', DATA . 'Font/');
// 字体目录
define('FILE', DATA . 'File/');
// 文件目录
define('LOCK', DATA . 'Lock/');
// 锁机制目录
defined('DEBUG') or define('DEBUG', FALSE);
// 调试模式
define('IS_CLI', !strcasecmp(php_sapi_name(), 'cli'));
// 命令行模式
// 自动加载
function __autoload($class)
{
    // 文件行号转换
    $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
    // 遍历目录
    foreach (array(APPLICATION, FRAMEWORK) as $dir) {
        // 完整文件名
        $file = "{$dir}{$class}.php";
        //是否加载
        if (is_file($file)) {
            require $file;
            break;
        }
    }
}
// 读取配置
\Core\C::load();