From f9fc4f110bbc8ccbf325903ca95ac77fb6523e2b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 5 Aug 2024 17:54:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bautoinc=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/PDOConnection.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/db/PDOConnection.php b/src/db/PDOConnection.php index b442eea5..599b2848 100644 --- a/src/db/PDOConnection.php +++ b/src/db/PDOConnection.php @@ -1002,7 +1002,7 @@ public function insert(BaseQuery $query, bool $getLastInsID = false) if ($lastInsId) { $pk = $query->getAutoInc(); - if ($pk) { + if ($pk && is_string($pk)) { $data[$pk] = $lastInsId; } } @@ -1283,7 +1283,7 @@ public function value(BaseQuery $query, string $field, $default = null, bool $on * * @return mixed */ - public function aggregate(BaseQuery $query, string $aggregate, string|Raw $field, bool $force = false) + public function aggregate(BaseQuery $query, string $aggregate, string | Raw $field, bool $force = false) { if (is_string($field) && 0 === stripos($field, 'DISTINCT ')) { [$distinct, $field] = explode(' ', $field); @@ -1766,12 +1766,8 @@ public function getLastInsID(BaseQuery $query, string $sequence = null) protected function autoInsIDType(BaseQuery $query, string $insertId) { $pk = $query->getAutoInc(); - - if (is_array($pk)) { - return $insertId; - } - if ($pk) { + if ($pk && is_string($pk)) { $type = $this->getFieldsBind($query->getTable())[$pk]; if (self::PARAM_INT == $type) {