mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进数据库类的一处不能嵌套查询的缺陷
This commit is contained in:
@@ -176,7 +176,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
// 设置当前模型 确保查询返回模型对象
|
// 设置当前模型 确保查询返回模型对象
|
||||||
$queryClass = $this->query ?: $con->getConfig('query');
|
$queryClass = $this->query ?: $con->getConfig('query');
|
||||||
$query = new $queryClass($con, $this->class);
|
$query = new $queryClass($con, $this->class);
|
||||||
$con->setQuery($query, $this->class);
|
|
||||||
|
|
||||||
// 设置当前数据表和模型名
|
// 设置当前数据表和模型名
|
||||||
if (!empty($this->table)) {
|
if (!empty($this->table)) {
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ abstract class Connection
|
|||||||
protected $attrCase = PDO::CASE_LOWER;
|
protected $attrCase = PDO::CASE_LOWER;
|
||||||
// 监听回调
|
// 监听回调
|
||||||
protected static $event = [];
|
protected static $event = [];
|
||||||
// 查询对象
|
|
||||||
protected $query = [];
|
|
||||||
// 使用Builder类
|
// 使用Builder类
|
||||||
protected $builder;
|
protected $builder;
|
||||||
// 数据库连接参数配置
|
// 数据库连接参数配置
|
||||||
@@ -137,32 +135,14 @@ abstract class Connection
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 指定当前使用的查询对象
|
* 获取新的查询对象
|
||||||
* @access public
|
* @access protected
|
||||||
* @param Query $query 查询对象
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setQuery($query, $model = 'db')
|
|
||||||
{
|
|
||||||
$this->query[$model] = $query;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建指定模型的查询对象
|
|
||||||
* @access public
|
|
||||||
* @return Query
|
* @return Query
|
||||||
*/
|
*/
|
||||||
public function getQuery($model = 'db')
|
protected function getQuery()
|
||||||
{
|
{
|
||||||
if (!isset($this->query[$model])) {
|
$class = $this->config['query'];
|
||||||
$class = $this->config['query'];
|
return new $class($this);
|
||||||
|
|
||||||
$this->query[$model] = new $class($this, 'db' == $model ? '' : $model);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->query[$model];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user