From 09402cee9be14333e580d954cd956fba17474dc9 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 14 Feb 2018 12:11:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=AF=B9=E4=B8=80?= =?UTF-8?q?=E5=85=B3=E8=81=94?= 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/HasOne.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/library/think/model/relation/BelongsTo.php b/library/think/model/relation/BelongsTo.php index 4765811e..ebef780c 100644 --- a/library/think/model/relation/BelongsTo.php +++ b/library/think/model/relation/BelongsTo.php @@ -128,6 +128,7 @@ class BelongsTo extends OneToOne } if (!empty($range)) { + $this->query->removeWhereField($localKey); $data = $this->eagerlyWhere($this->query, [ $localKey => [ 'in', diff --git a/library/think/model/relation/HasOne.php b/library/think/model/relation/HasOne.php index 46fedb87..dad8a7f2 100644 --- a/library/think/model/relation/HasOne.php +++ b/library/think/model/relation/HasOne.php @@ -130,7 +130,8 @@ class HasOne extends OneToOne } if (!empty($range)) { - $data = $this->eagerlyWhere($this, [ + $this->query->removeWhereField($foreignKey); + $data = $this->eagerlyWhere($this->query, [ $foreignKey => [ 'in', $range,