mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
修正Connection类
This commit is contained in:
@@ -175,7 +175,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
// 设置当前模型 确保查询返回模型对象
|
||||
$queryClass = $this->query ?: $con->getConfig('query');
|
||||
$query = new $queryClass($con, $this->class);
|
||||
$con->setQuery($query);
|
||||
$con->setQuery($query, $this->class);
|
||||
|
||||
// 设置当前数据表和模型名
|
||||
if (!empty($this->table)) {
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user