From cc573e4dbaaa7af0522c1e96c522d208bf432c72 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 7 Dec 2016 07:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BBsave=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=86=99=E5=85=A5=E5=AF=B9=E4=B8=BB=E9=94=AE=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/Model.php b/library/think/Model.php index 404e63de..93953f2c 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -728,7 +728,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $result = $this->db()->insert($this->data); // 获取自动增长主键 - if ($result && is_string($pk) && !isset($this->data[$pk])) { + if ($result && is_string($pk) && (!isset($this->data[$pk]) || '' == $this->data[$pk])) { $insertId = $this->db()->getLastInsID($sequence); if ($insertId) { $this->data[$pk] = $insertId;