From 6d8bcc86c3f9aba5a92010c17b68aeb8ad05ad3a Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 7 Nov 2024 17:12:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=81=9A=E5=90=88=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/relation/BelongsTo.php | 2 +- src/model/relation/HasMany.php | 2 +- src/model/relation/HasOne.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/model/relation/BelongsTo.php b/src/model/relation/BelongsTo.php index 78509b5f..1922f466 100644 --- a/src/model/relation/BelongsTo.php +++ b/src/model/relation/BelongsTo.php @@ -100,7 +100,7 @@ public function getRelationCountQuery(?Closure $closure = null, string $aggregat return $this->query ->whereExp($this->localKey, '=' . $this->parent->getTable(true) . '.' . $this->foreignKey) ->fetchSql() - ->$aggregate($this->localKey); + ->$aggregate($field); } /** diff --git a/src/model/relation/HasMany.php b/src/model/relation/HasMany.php index 4e2150cd..0ab0a85a 100644 --- a/src/model/relation/HasMany.php +++ b/src/model/relation/HasMany.php @@ -183,7 +183,7 @@ public function getRelationCountQuery(?Closure $closure = null, string $aggregat return $this->query->alias($aggregate . '_table') ->whereExp($aggregate . '_table.' . $this->foreignKey, '=' . $this->parent->getTable(true) . '.' . $this->localKey) ->fetchSql() - ->$aggregate($this->localKey); + ->$aggregate($field); } /** diff --git a/src/model/relation/HasOne.php b/src/model/relation/HasOne.php index ce983f29..6a5a56a3 100644 --- a/src/model/relation/HasOne.php +++ b/src/model/relation/HasOne.php @@ -100,7 +100,7 @@ public function getRelationCountQuery(?Closure $closure = null, string $aggregat return $this->query ->whereExp($this->foreignKey, '=' . $this->parent->getTable(true) . '.' . $this->localKey) ->fetchSql() - ->$aggregate($this->localKey); + ->$aggregate($field); } /**