From b377d97b805eed6cab95baaef6b106fca95a7e6e Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 1 Apr 2016 14:01:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Model=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 109b3aa28d..1385db6215 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -209,7 +209,7 @@ protected function _write_data($data, $type) throw new Exception('invalid data'); } } - if (!empty($this->duplicate) && 'update' == $type) { + if (isset($find) && !empty($this->duplicate) && 'update' == $type) { // 存在数据副本 foreach ($data as $key => $val) { // 去除相同数据 @@ -220,7 +220,7 @@ protected function _write_data($data, $type) if (empty($data)) { // 没有数据变化 return []; - } elseif (!empty($find)) { + } else { // 更新操作保留主键信息 $pk = $this->getPk(); if (is_array($pk)) {