From f3a0c1f77ecab2d912a52d9322cf00c8aad61b4b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 8 Apr 2016 14:37:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Model=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=99=A8=E6=96=B9=E6=B3=95=E6=89=A7=E8=A1=8C=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 79e1a4ed..8e225e10 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -179,7 +179,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // 标记字段更改 - if (isset($this->data[$name]) && $this->data[$name] != $value && !in_array($name, $this->change)) { + if (!isset($this->data[$name]) || (isset($this->data[$name]) && $this->data[$name] != $value && !in_array($name, $this->change))) { $this->change[] = $name; } // 设置数据对象属性 @@ -360,8 +360,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // 写入回调 $this->trigger('after_write', $this); - // 清空 - $this->isUpdate = null; + + // 标记为更新 + $this->isUpdate = true; return $result; }