This commit is contained in:
2021-02-23 18:21:07 +08:00
parent b1a9dc4155
commit 079a130695
+7 -3
View File
@@ -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);