From 079a13069578741b95f53515ee136a02bbf0c63b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 23 Feb 2021 18:21:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Database/Base/BaseActiveRecord.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 104c98c0..748b3ead 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -27,6 +27,7 @@ use Database\Relation; use Exception; use Snowflake\Exception\ComponentException; use Snowflake\Exception\NotFindClassException; +use static; use validator\Validator; use Database\IOrm; use Snowflake\Snowflake; @@ -431,17 +432,20 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess /** * @param $lastId * @param $param - * @return mixed + * @return static * @throws Exception */ - private function setPrimary($lastId, $param): mixed + private function setPrimary($lastId, $param): static { if ($this->hasAutoIncrement()) { - return $this->setAttribute($this->getAutoIncrement(), (int)$lastId); + $this->setAttribute($this->getAutoIncrement(), (int)$lastId); + return $this; } + if (!$this->hasPrimary()) { return $this; } + $primary = $this->getPrimary(); if (!isset($param[$primary]) || empty($param[$primary])) { $this->setAttribute($primary, (int)$lastId);