修正关联查询的软删除数据问题

This commit is contained in:
thinkphp
2017-04-07 17:28:17 +08:00
parent 92d775765b
commit 29846f5abc
4 changed files with 95 additions and 73 deletions

View File

@@ -57,7 +57,7 @@ abstract class Connection
// 监听回调
protected static $event = [];
// 查询对象
protected $query = [];
protected $query;
// 使用Builder类
protected $builder;
// 数据库连接参数配置
@@ -136,20 +136,33 @@ abstract class Connection
}
}
/**
* 指定当前使用的查询对象
* @access public
* @param Query $query 查询对象
* @return $this
*/
public function setQuery($query)
{
$this->query = $query;
return $this;
}
/**
* 创建指定模型的查询对象
* @access public
* @param string $model 模型类名称
* @param string $queryClass 查询对象类名
* @return Query
*/
public function getQuery($model = 'db', $queryClass = '')
public function getQuery()
{
if (!isset($this->query[$model])) {
$class = $queryClass ?: $this->config['query'];
$this->query[$model] = new $class($this, 'db' == $model ? '' : $model);
if (!isset($this->query)) {
$class = $this->config['query'];
$this->query = new $class($this);
}
return $this->query[$model];
return $this->query;
}
/**