mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 15:02:47 +08:00
修正Connection类
This commit is contained in:
@@ -175,7 +175,7 @@ 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);
|
$con->setQuery($query, $this->class);
|
||||||
|
|
||||||
// 设置当前数据表和模型名
|
// 设置当前数据表和模型名
|
||||||
if (!empty($this->table)) {
|
if (!empty($this->table)) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ abstract class Connection
|
|||||||
// 监听回调
|
// 监听回调
|
||||||
protected static $event = [];
|
protected static $event = [];
|
||||||
// 查询对象
|
// 查询对象
|
||||||
protected $query;
|
protected $query = [];
|
||||||
// 使用Builder类
|
// 使用Builder类
|
||||||
protected $builder;
|
protected $builder;
|
||||||
// 数据库连接参数配置
|
// 数据库连接参数配置
|
||||||
@@ -142,9 +142,9 @@ abstract class Connection
|
|||||||
* @param Query $query 查询对象
|
* @param Query $query 查询对象
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setQuery($query)
|
public function setQuery($query, $model = 'db')
|
||||||
{
|
{
|
||||||
$this->query = $query;
|
$this->query[$model] = $query;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -154,15 +154,15 @@ abstract class Connection
|
|||||||
* @access public
|
* @access public
|
||||||
* @return Query
|
* @return Query
|
||||||
*/
|
*/
|
||||||
public function getQuery()
|
public function getQuery($model = 'db')
|
||||||
{
|
{
|
||||||
if (!isset($this->query)) {
|
if (!isset($this->query[$model])) {
|
||||||
$class = $this->config['query'];
|
$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