From 30cc49abc71612ccc8bffba67c2332a44f34096a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 25 May 2017 11:04:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A8=A1=E5=9E=8B=E7=9A=84sa?= =?UTF-8?q?ve=E6=96=B9=E6=B3=95before=5Fupdate=E6=A3=80=E6=9F=A5=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 55e7da8e..493d055a 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -958,14 +958,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 自动更新 $this->autoCompleteData($this->update); - // 获取有更新的数据 - $data = $this->getChangedData(); - // 事件回调 if (false === $this->trigger('before_update', $this)) { return false; } + // 获取有更新的数据 + $data = $this->getChangedData(); + if (empty($data) || (count($data) == 1 && is_string($pk) && isset($data[$pk]))) { // 关联更新 if (isset($relation)) {