Example #1
0
 /**
  * 数据库工厂方法
  */
 public static function getDatabase($id = 'master')
 {
     //读取数据库配置文件
     if ($id == 'master') {
         $db_conf = Init::getInstance()->config['DataBase']['master'];
     } else {
         $db_conf = Init::getInstance()->config['DataBase']['slave'];
     }
     $key = 'database_' . $id;
     //获取数据库对象
     $db = Register::get($key);
     if (!$db) {
         $db = new MySQLi();
         $db->connect($db_conf['host'], $db_conf['user'], $db_conf['password'], $db_conf['dbname']);
         Register::set($key, $db);
     }
     return $db;
 }
Example #2
0
<?php

$start = microtime(true);
error_reporting(E_ALL);
define('__AUTH', 'Until Die');
if (defined('DIRECTORY_SEPARATOR')) {
    define('DS', DIRECTORY_SEPARATOR);
} else {
    define('DS', '/');
}
if (is_callable('realpath')) {
    define('BASE_PATH', realpath(dirname(__FILE__)));
} else {
    define('BASE_PATH', dirname(__FILE__));
}
define('SYS_PATH', BASE_PATH . DS . 'system');
define('APP_PATH', BASE_PATH . DS . 'application');
require SYS_PATH . DS . 'initialize.php';
try {
    Init::getInstance();
    Init::Router('loader');
} catch (Exception $exc) {
    include SYS_PATH . DS . 'error.php';
}
$end = microtime(true);
echo '<p sytle="margin: auto 20px;">' . round($end - $start, 4) . ' Sec</p>';
Example #3
0
 /**
  * 构造函数
  */
 public function __construct()
 {
     $this->config = Init::getInstance()->config;
     $this->template_dir = Init::getInstance()->base_dir . '/tpl/';
 }