From 01c3d3494027710d274dc7fb0fa28ad3188d321a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 8 Oct 2016 14:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BB=E7=9A=84save?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index f062e3c5..b9b55c44 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -680,15 +680,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $where = $this->updateWhere; } - if (!empty($where)) { - $pk = $this->getPk(); - if (is_string($pk) && isset($data[$pk])) { - if (!isset($where[$pk])) { - unset($where); - $where[$pk] = $data[$pk]; - } - unset($data[$pk]); + $pk = $this->getPk(); + if (is_string($pk) && isset($data[$pk])) { + if (!isset($where[$pk])) { + unset($where); + $where[$pk] = $data[$pk]; } + unset($data[$pk]); } $result = $this->db()->where($where)->update($data);