From 7ccf303cf6b6a4999e24a63a440edc9aa2529363 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Dec 2017 21:51:11 +0800 Subject: [PATCH] =?UTF-8?q?save=E6=96=B9=E6=B3=95=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E5=A4=8D=E5=90=88=E4=B8=BB=E9=94=AE=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 99105caa..391f78b6 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1070,12 +1070,17 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } } - if (is_string($pk) && isset($data[$pk])) { - if (!isset($where[$pk])) { - unset($where); - $where[$pk] = $data[$pk]; + $array = []; + + foreach ((array) $pk as $key) { + if (isset($data[$key])) { + $array[] = [$key, '=', $data[$key]]; + unset($data[$key]); } - unset($data[$pk]); + } + + if (!empty($array)) { + $where = $array; } // 检测字段