From e7ab1e9a2d938212d84dfe51ea46b0bc1665a02b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 21 Nov 2017 15:36:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 8 ++++---- library/think/model/Pivot.php | 4 ++-- library/think/model/relation/BelongsToMany.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index f7d299a2..a39f2387 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -2361,8 +2361,8 @@ class Query if (count($resultSet) > 0) { foreach ($resultSet as $key => $result) { /** @var Model $model */ - $model = new $modelName(); - $model->data($result)->isUpdate(true); + $model = new $modelName($result); + $model->isUpdate(true); // 关联查询 if (!empty($options['relation'])) { @@ -2518,8 +2518,8 @@ class Query if (!empty($this->model)) { // 返回模型对象 $model = $this->model; - $result = new $model(); - $result->data($result)->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null); + $result = new $model($result); + $result->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null); // 关联查询 if (!empty($options['relation'])) { $result->relationQuery($options['relation']); diff --git a/library/think/model/Pivot.php b/library/think/model/Pivot.php index 259a8a03..8c04266d 100644 --- a/library/think/model/Pivot.php +++ b/library/think/model/Pivot.php @@ -24,11 +24,11 @@ class Pivot extends Model /** * 架构函数 * @access public - * @param Model $parent 上级模型 * @param array|object $data 数据 + * @param Model $parent 上级模型 * @param string $table 中间数据表名 */ - public function __construct(Model $parent = null, $data = [], $table = '') + public function __construct($data = [], Model $parent = null, $table = '') { $this->parent = $parent; diff --git a/library/think/model/relation/BelongsToMany.php b/library/think/model/relation/BelongsToMany.php index 7460547b..1a2a7ebd 100644 --- a/library/think/model/relation/BelongsToMany.php +++ b/library/think/model/relation/BelongsToMany.php @@ -74,7 +74,7 @@ class BelongsToMany extends Relation protected function newPivot($data = []) { $class = $this->pivotName ?: '\\think\\model\\Pivot'; - $pivot = new $class($this->parent, $data, $this->middle); + $pivot = new $class($data, $this->parent, $this->middle); if ($pivot instanceof Pivot) { return $pivot; } else {