From 28254c8126bc5ec450340ccc979cde9071e2565c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 31 May 2016 18:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Query=E7=B1=BB=E7=9A=84inserG?= =?UTF-8?q?etId=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index bf883a83..fd1f6c4a 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1437,16 +1437,18 @@ class Query * @param mixed $data 数据 * @param boolean $replace 是否replace * @param boolean $getLastInsID 是否获取自增ID + * @param string $sequence 自增序列名 * @return integer */ - public function insert(array $data, $replace = false, $getLastInsID = false) + public function insert(array $data, $replace = false, $getLastInsID = false, $sequence = null) { // 分析查询表达式 $options = $this->parseExpress(); // 生成SQL语句 - $sql = $this->builder()->insert($data, $options, $replace); + $sql = $this->builder()->insert($data, $options, $replace); + $sequence = $sequence ?: (isset($options['sequence']) ? $options['sequence'] : null); // 执行操作 - return $this->execute($sql, $this->getBind(), $options['fetch_sql'], $getLastInsID, isset($options['sequence']) ? $options['sequence'] : null); + return $this->execute($sql, $this->getBind(), $options['fetch_sql'], $getLastInsID, $sequence); } /**