From ac528e0680c6da8bceb9116851edc285d7ed3311 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 5 Aug 2016 10:34:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=BD=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E9=A9=B1=E5=8A=A8=E7=B1=BB=E5=9E=8B=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=20Query=E7=B1=BB=E7=9A=84builder=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 2 ++ library/think/db/Query.php | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index b92aea6d..6712e0d9 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -105,6 +105,8 @@ abstract class Connection 'auto_timestamp' => false, // 是否需要进行SQL性能分析 'sql_explain' => false, + // Builder类 + 'builder' => '', ]; // PDO连接参数 diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 33d2d1f6..2fab3b17 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -34,7 +34,7 @@ class Query // 数据库Connection对象实例 protected $connection; // 数据库驱动类型 - protected $driver; + protected $builder; // 当前模型类名称 protected $model; // 当前数据表名称(含前缀) @@ -59,7 +59,7 @@ class Query public function __construct(Connection $connection = null, $model = '') { $this->connection = $connection ?: Db::connect([], true); - $this->driver = $this->connection->getConfig('type'); + $this->builder = $this->connection->getConfig('builder') ?: $this->connection->getConfig('type'); $this->prefix = $this->connection->getConfig('prefix'); $this->model = $model; } @@ -357,7 +357,7 @@ class Query protected function builder() { static $builder = []; - $driver = $this->driver; + $driver = $this->builder; if (!isset($builder[$driver])) { $class = false !== strpos($driver, '\\') ? $driver : '\\think\\db\\builder\\' . ucfirst($driver); $builder[$driver] = new $class($this->connection);