From 5706ed7e44e071ef173e3d39bb5549f683074c89 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 24 Nov 2017 17:22:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BhasWhere=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/BelongsTo.php | 1 + library/think/model/relation/HasMany.php | 1 + 2 files changed, 2 insertions(+) diff --git a/library/think/model/relation/BelongsTo.php b/library/think/model/relation/BelongsTo.php index 9b66e0c3..45118fc9 100644 --- a/library/think/model/relation/BelongsTo.php +++ b/library/think/model/relation/BelongsTo.php @@ -97,6 +97,7 @@ class BelongsTo extends OneToOne } return $this->parent->db()->alias($model) ->field($model . '.*') + ->group($model . '.' . $this->foreignKey) ->join($table . ' ' . $relation, $model . '.' . $this->foreignKey . '=' . $relation . '.' . $this->localKey, $this->joinType) ->where($where); } diff --git a/library/think/model/relation/HasMany.php b/library/think/model/relation/HasMany.php index eb9bf66d..ccc210e3 100644 --- a/library/think/model/relation/HasMany.php +++ b/library/think/model/relation/HasMany.php @@ -271,6 +271,7 @@ class HasMany extends Relation } return $this->parent->db()->alias($model) ->field($model . '.*') + ->group($model . '.' . $this->localKey) ->join($table . ' ' . $relation, $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey) ->where($where); }