mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Query类的setBuilder方法 避免因自定义连接器类后找不到生成器类
This commit is contained in:
@@ -58,6 +58,8 @@ abstract class Connection
|
|||||||
protected static $event = [];
|
protected static $event = [];
|
||||||
// 查询对象
|
// 查询对象
|
||||||
protected $query = [];
|
protected $query = [];
|
||||||
|
// 使用Builder类
|
||||||
|
protected $builder;
|
||||||
// 数据库连接参数配置
|
// 数据库连接参数配置
|
||||||
protected $config = [
|
protected $config = [
|
||||||
// 数据库类型
|
// 数据库类型
|
||||||
@@ -148,6 +150,20 @@ abstract class Connection
|
|||||||
return $this->query[$model];
|
return $this->query[$model];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前连接器类对应的Builder类
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getBuilder()
|
||||||
|
{
|
||||||
|
if (!empty($this->builder)) {
|
||||||
|
return $this->builder;
|
||||||
|
} else {
|
||||||
|
return $this->getConfig('builder') ?: '\\think\\db\\builder\\' . ucfirst($this->getConfig('type'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用Query类的查询方法
|
* 调用Query类的查询方法
|
||||||
* @access public
|
* @access public
|
||||||
|
|||||||
@@ -124,8 +124,7 @@ class Query
|
|||||||
*/
|
*/
|
||||||
protected function setBuilder()
|
protected function setBuilder()
|
||||||
{
|
{
|
||||||
$builder = $this->connection->getConfig('builder') ?: $this->connection->getConfig('type');
|
$class = $this->connection->getBuilder();
|
||||||
$class = false !== strpos($builder, '\\') ? $builder : '\\think\\db\\builder\\' . ucfirst($builder);
|
|
||||||
$this->builder = new $class($this->connection, $this);
|
$this->builder = new $class($this->connection, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user