From 37009c3f5937b8ee45990c40608bc94166b1ad3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 7 Apr 2023 21:57:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Base/Model.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Base/Model.php b/Base/Model.php index 1bd10b9..12d53fc 100644 --- a/Base/Model.php +++ b/Base/Model.php @@ -551,10 +551,14 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T if ($this->hasPrimary()) { $condition = [$this->getPrimary() => $this->getPrimaryValue()]; } - $generate = SqlBuilder::builder(static::query()->where($condition))->update($param); + + $query = static::query()->where($condition); + $generate = SqlBuilder::builder($query)->update($param); if (is_bool($generate)) { return $generate; } + + $generate[1] = array_merge($query->attributes, $generate[1]); $command = $this->getConnection()->createCommand($generate[0], $generate[1]); if ($command->save()) { return $this->refresh()->afterSave($fields, $param);