Exemple #1
0
 static function getDatabase($id = 'master')
 {
     $key = 'database_' . $id;
     if ($id == 'slave') {
         $slaves = \system\Application::getInstance()->config['database']['slave'];
         #随机取从数据库
         $db_config = $slaves[array_rand($slaves)];
     } else {
         $db_config = \system\Application::getInstance();
         $db_config = $db_config[$id];
     }
     //如果已经被注册,直接取实例
     $db = \system\register\Register::get($key);
     if (!$db) {
         $db = new \system\database\Database();
         //链接配置
         $db->connect($db_config['host'], $db_config['user'], $db_config['password'], $db_config['dbname']);
         //注册实例
         \system\register\Register::set($key, $db);
     }
     return $db;
 }
Exemple #2
0
<?php

#~ Set Application's Root Directory!
define('DocRoot', str_replace("\\", "/", dirname(__FILE__)));
#~ Include System files!
require_once DocRoot . '/core/internal_variables.php';
require_once DocRoot . '/core/internal_functions.php';
require_once DocRoot . '/core/internal_oop.php';
require_once DocRoot . '/core/application.php';
require_once DocRoot . '/core/session.php';
require_once DocRoot . '/core/theme.php';
require_once DocRoot . '/core/clock.php';
require_once DocRoot . '/core/user.php';
#~ Initialize & Bootstrap application!
$app = \System\Application::Get();
$app->Boot();
#~ If Application is Not Offline, Process the request
if ($app->IsOffline()) {
    #$app->Enabl
} else {
    $app->Execute();
}
#~ Make the sub calculations & Turn off the Application
#~ Javascript, CSS, other Head / Closure Items, will be applied..
$html = $app->TurnOff();
#~ We will reach here only for HTML pages; XML / JSON / etc.. would have been already sent!
#~ So go ahead and display the Active Theme Template
$html->Display();