From fc2a7b48096a8ccbf6d656cef1f200ec7410c20c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 18 Feb 2016 11:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Model=E7=B1=BB=20=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=89=AF=E6=9C=AC=E6=AF=94=E8=BE=83=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E4=B8=80=E5=A4=84=E8=AD=A6=E5=91=8A=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index d911d2fd..5078d3dc 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -206,14 +206,17 @@ class Model } if (!empty($this->duplicate)) { // 存在数据副本 - $data = array_diff_assoc($data, $this->duplicate); + foreach ($data as $key => $val) { + // 去除相同数据 + if (isset($this->duplicate[$key]) && $val == $this->duplicate[$key]) { + unset($data[$key]); + } + } if (empty($data)) { // 没有数据变化 return []; - } - - if ('update' == $type) { - // 保留主键信息 + } elseif ('update' == $type) { + // 更新操作保留主键信息 $pk = $this->getPk(); if (is_array($pk)) { foreach ($pk as $key) {