From 2d00377a0b65eafbe999343750790f9c51b0816f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 24 Dec 2015 15:38:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=85=88=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=20=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95test=E6=A0=B9=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E7=A9=BA=E9=97=B4=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db.php | 16 ++++++++-------- start.php | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/think/db.php b/library/think/db.php index 75b5ba00..5459f236 100644 --- a/library/think/db.php +++ b/library/think/db.php @@ -17,9 +17,9 @@ namespace think; class Db { // 数据库连接实例 - private static $instance = []; + private static $instances = []; // 当前数据库连接实例 - private static $_instance = null; + private static $instance = null; // 查询次数 public static $queryTimes = 0; // 执行次数 @@ -36,15 +36,15 @@ class Db public static function instance($config = [], $lite = false) { $md5 = md5(serialize($config)); - if (!isset(self::$instance[$md5])) { + if (!isset(self::$instances[$md5])) { // 解析连接参数 支持数组和字符串 $options = self::parseConfig($config); // 如果采用lite方式 仅支持原生SQL 包括query和execute方法 - $class = $lite ? '\\think\\db\\Lite' : '\\think\\db\\driver\\' . ucwords($options['type']); - self::$instance[$md5] = new $class($options); + $class = $lite ? '\\think\\db\\Lite' : '\\think\\db\\driver\\' . ucwords($options['type']); + self::$instances[$md5] = new $class($options); } - self::$_instance = self::$instance[$md5]; - return self::$_instance; + self::$instance = self::$instances[$md5]; + return self::$instance; } /** @@ -106,6 +106,6 @@ class Db // 调用驱动类的方法 public static function __callStatic($method, $params) { - return call_user_func_array([self::$_instance, $method], $params); + return call_user_func_array([self::$instance, $method], $params); } } diff --git a/start.php b/start.php index cb3b98a8..765aa00e 100644 --- a/start.php +++ b/start.php @@ -46,6 +46,6 @@ if (APP_HOOK && isset($mode['tags'])) { if (APP_AUTO_BUILD && is_file(APP_PATH . 'build.php')) { Build::run(include APP_PATH . 'build.php'); } - +Loader::addNamespace('tests', TEST_PATH); // 执行应用 !IN_UNIT_TEST && App::run();