From d376042361b6d1cdf0d159010b913fea18a5931e Mon Sep 17 00:00:00 2001 From: "as2252258@163.com" Date: Sun, 2 May 2021 04:50:45 +0800 Subject: [PATCH] modify --- Database/ActiveRecord.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index bd1b493a..b581b8fb 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -342,7 +342,7 @@ class ActiveRecord extends BaseActiveRecord */ public function hasOne(string $modelName, $foreignKey, $localKey): HasOne|ActiveQuery { - if (!$this->has($localKey)) { + if (!isset($this->attributes[$localKey])) { throw new Exception("Need join table primary key."); } @@ -363,7 +363,7 @@ class ActiveRecord extends BaseActiveRecord */ public function hasCount($modelName, $foreignKey, $localKey): mixed { - if (!$this->has($localKey)) { + if (!isset($this->attributes[$localKey])) { throw new Exception("Need join table primary key."); } @@ -384,7 +384,7 @@ class ActiveRecord extends BaseActiveRecord */ public function hasMany($modelName, $foreignKey, $localKey): mixed { - if (!$this->has($localKey)) { + if (!isset($this->attributes[$localKey])) { throw new Exception("Need join table primary key."); }