From 61235ed60af3185d72d16aa944a5bc60e855f452 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 27 Dec 2017 21:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 40608296..99105caa 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1124,10 +1124,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess // 获取自动增长主键 if ($result && $insertId = $this->getQuery()->getLastInsID($sequence)) { - $pks = (array) $pk; - foreach ($pks as $pk) { - if (!isset($this->data[$pk]) || '' == $this->data[$pk]) { - $this->data[$pk] = $insertId; + foreach ((array) $pk as $key) { + if (!isset($this->data[$key]) || '' == $this->data[$key]) { + $this->data[$key] = $insertId; } } }