From ea9041b858c9253fac422be5fc7fc402d7869fdf Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 11 Dec 2015 08:32:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db.php | 6 +++--- library/think/db/lite.php | 16 +++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/library/think/db.php b/library/think/db.php index 2ae2a682..6fadfcf0 100644 --- a/library/think/db.php +++ b/library/think/db.php @@ -17,9 +17,9 @@ namespace think; class Db { // 数据库连接实例 - private static $instance = []; + private static $instance = []; // 当前数据库连接实例 - private static $_instance = null; + private static $_instance = null; /** * 取得数据库类实例 @@ -36,7 +36,7 @@ class Db // 解析连接参数 支持数组和字符串 $options = self::parseConfig($config); // 如果采用lite方式 仅支持原生SQL 包括query和execute方法 - $class = $lite ? 'think\\db\\lite' : 'think\\db\\driver\\' . strtolower($options['type']); + $class = $lite ? '\\think\\db\\Lite' : '\\think\\db\\driver\\' . ucwords($options['type']); self::$instance[$md5] = new $class($options); } self::$_instance = self::$instance[$md5]; diff --git a/library/think/db/lite.php b/library/think/db/lite.php index 0331fed8..1a4ac592 100644 --- a/library/think/db/lite.php +++ b/library/think/db/lite.php @@ -348,7 +348,7 @@ class Lite // 记录错误日志 Log::record($this->error, 'ERR'); if ($this->config['debug']) { -// 开启数据库调试模式 + // 开启数据库调试模式 throw new Exception($this->error); } else { return $this->error; @@ -416,7 +416,7 @@ class Lite protected function debug($start) { if ($this->config['debug']) { -// 开启数据库调试模式 + // 开启数据库调试模式 if ($start) { Debug::remark('queryStartTime', 'time'); } else { @@ -437,13 +437,11 @@ class Lite */ protected function initConnect($master = true) { - if (!empty($this->config['deploy'])) - // 采用分布式数据库 - { + if (!empty($this->config['deploy'])) { + // 采用分布式数据库 $this->_linkID = $this->multiConnect($master); - } else - // 默认单数据库 - if (!$this->_linkID) { + } elseif (!$this->_linkID) { + // 默认单数据库 $this->_linkID = $this->connect(); } @@ -476,7 +474,7 @@ class Lite $r = floor(mt_rand(0, $this->config['master_num'] - 1)); } else { if (is_numeric($this->config['slave_no'])) { -// 指定服务器读 + // 指定服务器读 $r = $this->config['slave_no']; } else { // 读操作连接从服务器