From 53c06a8015eeffbabd259b1a280f9ff51b82182f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 12 Aug 2016 15:15:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BBcreate=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20=E5=A2=9E=E5=8A=A0getId=E5=8F=82=E6=95=B0=20saveAll?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20getId=E5=8F=82=E6=95=B0=E4=B8=BAfalse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 3b95aad7..d09322c4 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -728,7 +728,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess $db->startTrans(); try { foreach ($dataSet as $key => $data) { - $result[$key] = self::create($data, $replace); + $result[$key] = self::create($data, $replace, false); } $db->commit(); return $result; @@ -942,12 +942,13 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * @access public * @param array $data 数据数组 * @param bool $replace 是否replace + * @param bool $getId 是否返回自增主键 * @return $this */ - public static function create($data = [], $replace = false) + public static function create($data = [], $replace = false, $getId = true) { $model = new static(); - $model->isUpdate(false)->save($data, [], true, $replace); + $model->isUpdate(false)->save($data, [], $getId, $replace); return $model; }