From 7c7948d44b2d4a7d5084b9cc06aeab581c0dba2e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 4 May 2016 17:00:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BDb=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 +- library/think/Db.php | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/convention.php b/convention.php index d06ffc9d..9be115ea 100644 --- a/convention.php +++ b/convention.php @@ -41,7 +41,7 @@ return [ // 默认模块名 'default_module' => 'index', // 禁止访问模块 - 'deny_module_list' => [COMMON_MODULE, 'runtime'], + 'deny_module_list' => [COMMON_MODULE], // 默认控制器名 'default_controller' => 'Index', // 默认操作名 diff --git a/library/think/Db.php b/library/think/Db.php index 9d1740d9..832ed66d 100644 --- a/library/think/Db.php +++ b/library/think/Db.php @@ -18,8 +18,6 @@ class Db { // 数据库连接实例 private static $instances = []; - // 当前数据库连接实例 - private static $instance = null; // 查询次数 public static $queryTimes = 0; // 执行次数 @@ -46,8 +44,7 @@ class Db // 记录初始化信息 APP_DEBUG && Log::record('[ DB ] INIT ' . $options['type'] . ':' . var_export($options, true), 'info'); } - self::$instance = self::$instances[$md5]; - return self::$instance; + return self::$instances[$md5]; } /** @@ -107,10 +104,7 @@ class Db // 调用驱动类的方法 public static function __callStatic($method, $params) { - if (is_null(self::$instance)) { - // 自动初始化数据库 - self::connect(); - } - return call_user_func_array([self::$instance, $method], $params); + // 自动初始化数据库 + return call_user_func_array([self::connect(), $method], $params); } }