From 05f90fe4a4b235f33884ef383df3e95dfd32e32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 17 Aug 2023 17:33:28 +0800 Subject: [PATCH] qqq --- Base/Model.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Base/Model.php b/Base/Model.php index 14c6ed2..fef14f9 100644 --- a/Base/Model.php +++ b/Base/Model.php @@ -188,7 +188,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T */ public function hasPrimary(): bool { - return $this->primary !== NULL && $this->primary !== ''; + return !empty($this->primary); } /** @@ -223,6 +223,9 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T */ public function getPrimaryValue(): ?int { + if (!$this->hasPrimary()) { + return null; + } return $this->_oldAttributes[$this->getPrimary()] ?? null; }