mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
改进当数据库驱动类型使用完整命名空间的时候 Query类的builder方法的问题
This commit is contained in:
@@ -105,6 +105,8 @@ abstract class Connection
|
||||
'auto_timestamp' => false,
|
||||
// 是否需要进行SQL性能分析
|
||||
'sql_explain' => false,
|
||||
// Builder类
|
||||
'builder' => '',
|
||||
];
|
||||
|
||||
// PDO连接参数
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user