From 96c7d2c25a54e44794bbea28a6cfb291d42e2b35 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 8 Apr 2016 17:16:15 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E7=9A=84save=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E6=9B=B4=E6=96=B0=E6=9D=A1=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=20=E6=A0=87=E8=AF=86=E4=B8=BA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 6ed60d50..38421202 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -59,10 +59,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 字段类型或者格式转换 protected $type = []; - // 当前执行的关联类型 - private $relation; // 是否为更新数据 protected $isUpdate = false; + // 当前执行的关联类型 + private $relation; /** * 初始化过的模型. @@ -108,9 +108,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * @return void */ protected static function init() - { - - } + {} // JsonSerializable public function jsonSerialize() @@ -331,6 +329,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess foreach ($data as $key => $value) { $this->__set($key, $value); } + if (!empty($where)) { + $this->isUpdate = true; + } } // 数据自动验证 if (!$this->validateData()) {