From cfea3a40724ae91f561360e7d86f2a7039a80cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 16 Sep 2020 21:27:23 +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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index a6ff3167..69f48663 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -137,7 +137,7 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess } $primary = static::getColumns()->getPrimaryKeys(); if (!empty($primary)) { - return $this->primary = current($primary); + return $this->primary = is_array($primary) ? current($primary) : $primary; } return false; } @@ -196,7 +196,10 @@ abstract class BaseActiveRecord extends Component implements IOrm, \ArrayAccess if (empty($primary)) { throw new Exception('Primary key cannot be empty.'); } - $condition = [current($primary) => $condition]; + if (is_array($primary)) { + $primary = current($primary); + } + $condition = [$primary => $condition]; } return static::find()->where($condition)->first(); }