改进数据库类的一处不能嵌套查询的缺陷

This commit is contained in:
thinkphp
2017-05-11 18:39:06 +08:00
parent 7576b88c99
commit 6e721239ea
2 changed files with 5 additions and 26 deletions

View File

@@ -56,8 +56,6 @@ abstract class Connection
protected $attrCase = PDO::CASE_LOWER;
// 监听回调
protected static $event = [];
// 查询对象
protected $query = [];
// 使用Builder类
protected $builder;
// 数据库连接参数配置
@@ -137,32 +135,14 @@ abstract class Connection
}
/**
* 指定当前使用的查询对象
* @access public
* @param Query $query 查询对象
* @return $this
*/
public function setQuery($query, $model = 'db')
{
$this->query[$model] = $query;
return $this;
}
/**
* 创建指定模型的查询对象
* @access public
* 获取新的查询对象
* @access protected
* @return Query
*/
public function getQuery($model = 'db')
protected function getQuery()
{
if (!isset($this->query[$model])) {
$class = $this->config['query'];
$this->query[$model] = new $class($this, 'db' == $model ? '' : $model);
}
return $this->query[$model];
$class = $this->config['query'];
return new $class($this);
}
/**