From dcc1ac2bb42e05f8bc9784d0b82ca7fbc46468e5 Mon Sep 17 00:00:00 2001 From: bazhe <1031601644@qq.com> Date: Wed, 6 Mar 2024 18:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=AF=B9=E5=A4=9A?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=9A=84withCount=E8=87=AA=E5=85=B3=E8=81=94?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20=E5=8F=82=E7=85=A7https://github.com/top-t?= =?UTF-8?q?hink/framework/commit/98af9cd4f6da08168fd83045f52111f15ef85b20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9A=84=EF=BC=8C=E6=B2=BB=E6=A0=87=E4=B8=8D?= =?UTF-8?q?=E6=B2=BB=E6=9C=AC=EF=BC=8C=E4=BD=86=E6=98=AF=E8=83=BD=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/HasMany.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/think/model/relation/HasMany.php b/library/think/model/relation/HasMany.php index ebab051a..240d2ca4 100644 --- a/library/think/model/relation/HasMany.php +++ b/library/think/model/relation/HasMany.php @@ -164,7 +164,7 @@ class HasMany extends Relation } } $localKey = $this->localKey ?: $this->parent->getPk(); - return $this->query->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $localKey)->fetchSql()->count(); + return $this->query->alias( 'count_table')->whereExp( 'count_table.' . $this->foreignKey, '=' . $this->parent->getTable() . '.' . $localKey)->fetchSql()->count(); } /** -- Gitee