From 4989d2ad55a9ccc881454967deb468504352b652 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 21 Jun 2016 15:14:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BModel=E7=B1=BBsaveall?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84=E8=BF=94=E5=9B=9E=E5=80=BC=20?= =?UTF-8?q?=E5=B9=B6=E5=A2=9E=E5=8A=A0replace=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 49c6434d..3863c260 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -632,17 +632,18 @@ abstract class Model implements \JsonSerializable, \ArrayAccess /** * 保存多个数据到当前数据对象 * @access public - * @param array $data 数据 + * @param array $dataSet 数据 + * @param bool $replace 是否replace * @return array|false */ - public function saveAll($dataSet) + public function saveAll($dataSet, $repalce = false) { $result = []; $db = $this->db(); $db->startTrans(); try { - foreach ($dataSet as $data) { - $result[] = $this->isUpdate(false)->save($data, [], true); + foreach ($dataSet as $key => $data) { + $result[$key] = self::create($data, $replace); } $db->commit(); return $result;