修正Connection类

This commit is contained in:
thinkphp
2017-04-07 19:02:05 +08:00
parent f1366f7833
commit a05397b341
2 changed files with 8 additions and 8 deletions

View File

@@ -57,7 +57,7 @@ abstract class Connection
// 监听回调
protected static $event = [];
// 查询对象
protected $query;
protected $query = [];
// 使用Builder类
protected $builder;
// 数据库连接参数配置
@@ -142,9 +142,9 @@ abstract class Connection
* @param Query $query 查询对象
* @return $this
*/
public function setQuery($query)
public function setQuery($query, $model = 'db')
{
$this->query = $query;
$this->query[$model] = $query;
return $this;
}
@@ -154,15 +154,15 @@ abstract class Connection
* @access public
* @return Query
*/
public function getQuery()
public function getQuery($model = 'db')
{
if (!isset($this->query)) {
if (!isset($this->query[$model])) {
$class = $this->config['query'];
$this->query = new $class($this);
$this->query[$model] = new $class($this, 'db' == $model ? '' : $model);
}
return $this->query;
return $this->query[$model];
}
/**