From 3278a7d628c94f3bfbef36fba43b6abb20608135 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 5 Aug 2016 11:09:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Relation=E7=B1=BB=E7=9A=84?= =?UTF-8?q?=E4=B8=80=E5=AF=B9=E5=A4=9A=E5=85=B3=E8=81=94=E9=A2=84=E8=BD=BD?= =?UTF-8?q?=E5=85=A5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/Relation.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index 94525f76..6b1faa32 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -93,7 +93,7 @@ class Relation $result = $relation->where($localKey, $this->parent->$foreignKey)->find(); break; case self::HAS_MANY: - $result = $relation->select(); + $result = $relation->where($foreignKey, $this->parent->$localKey)->select(); break; case self::HAS_MANY_THROUGH: $result = $relation->select(); @@ -659,12 +659,6 @@ class Relation { if ($this->query) { switch ($this->type) { - case self::HAS_MANY: - if (isset($this->parent->{$this->localKey})) { - // 关联查询带入关联条件 - $this->query->where($this->foreignKey, $this->parent->{$this->localKey}); - } - break; case self::HAS_MANY_THROUGH: $through = $this->middle; $model = $this->model;