改进中间表模型的实例化

This commit is contained in:
thinkphp
2017-11-21 15:17:52 +08:00
parent 1bbf37a20b
commit c38d2a6d0d

View File

@@ -2361,8 +2361,8 @@ class Query
if (count($resultSet) > 0) { if (count($resultSet) > 0) {
foreach ($resultSet as $key => $result) { foreach ($resultSet as $key => $result) {
/** @var Model $model */ /** @var Model $model */
$model = new $modelName($result); $model = new $modelName();
$model->isUpdate(true); $model->data($result)->isUpdate(true);
// 关联查询 // 关联查询
if (!empty($options['relation'])) { if (!empty($options['relation'])) {
@@ -2518,8 +2518,8 @@ class Query
if (!empty($this->model)) { if (!empty($this->model)) {
// 返回模型对象 // 返回模型对象
$model = $this->model; $model = $this->model;
$result = new $model($result); $result = new $model();
$result->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null); $result->data($result)->isUpdate(true, isset($options['where']['AND']) ? $options['where']['AND'] : null);
// 关联查询 // 关联查询
if (!empty($options['relation'])) { if (!empty($options['relation'])) {
$result->relationQuery($options['relation']); $result->relationQuery($options['relation']);