Пример #1
0
 public static function get_instance($db_driver, $db_host, $db_username, $db_password, $db_name, $db_prefix)
 {
     if (self::$instance == null) {
         require_once BASEPATH . 'database/DB' . EXT;
         $params = array('dbdriver' => $db_driver, 'hostname' => $db_host, 'username' => $db_username, 'password' => $db_password, 'database' => $db_name, 'dbprefix' => $db_prefix, 'pconnect' => FALSE, 'db_debug' => FALSE, 'cache_on' => FALSE, 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci');
         self::$instance = DB($params, TRUE);
     }
     return self::$instance;
 }
Пример #2
0
// Configuration
if (is_file('config.php')) {
    require_once 'config.php';
}
// Startup
require_once DIR_SYSTEM . 'startup.php';
// Registry
$registry = new Registry();
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// 集成codeigniter的数据访问
$db_ci = DB_CI::get_instance(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX);
$registry->set('db_ci', $db_ci);
// Settings
$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0'");
foreach ($query->rows as $setting) {
    if (!$setting['serialized']) {
        $config->set($setting['key'], $setting['value']);
    } else {
        $config->set($setting['key'], unserialize($setting['value']));
    }
}
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Url
$url = new Url(HTTP_SERVER, $config->get('config_secure') ? HTTPS_SERVER : HTTP_SERVER);