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);