mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-09 08:02:48 +08:00
修正Query类的builder方法
This commit is contained in:
@@ -853,10 +853,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
|
||||
if (!isset(self::$links[$model])) {
|
||||
self::$links[$model] = Db::connect(static::$connection);
|
||||
}
|
||||
self::$links[$model]->setTable(static::$tableName);
|
||||
$name = basename(str_replace('\\', '/', $model));
|
||||
self::$links[$model]->name($name);
|
||||
}
|
||||
|
||||
// 设置当前模型 确保查询返回模型对象
|
||||
self::$links[$model]->model($model);
|
||||
// 返回当前数据库对象
|
||||
|
||||
@@ -38,9 +38,19 @@ abstract class Builder
|
||||
* @access public
|
||||
* @param object $db 数据库对象实例
|
||||
*/
|
||||
public function __construct($connection, $query)
|
||||
public function __construct($connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前的Query对象实例
|
||||
* @access protected
|
||||
* @param \think\db\Query $query 当前查询对象实例
|
||||
* @return void
|
||||
*/
|
||||
public function setQuery($query)
|
||||
{
|
||||
$this->query = $query;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,10 @@ class Query
|
||||
$driver = $this->driver;
|
||||
if (!isset($builder[$driver])) {
|
||||
$class = '\\think\\db\\builder\\' . ucfirst($driver);
|
||||
$builder[$driver] = new $class($this->connection, $this);
|
||||
$builder[$driver] = new $class($this->connection);
|
||||
}
|
||||
// 设置当前查询对象
|
||||
$builder[$driver]->setQuery($this);
|
||||
return $builder[$driver];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user