From 0f58b08becd38923e582ff77cdd1a79be1f09157 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 2 Jul 2016 18:51:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=A4=9A=E5=AF=B9=E5=A4=9A?= =?UTF-8?q?=E9=A2=84=E8=BD=BD=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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/think/model/Relation.php b/library/think/model/Relation.php index a065524c..3c95eb4b 100644 --- a/library/think/model/Relation.php +++ b/library/think/model/Relation.php @@ -197,7 +197,7 @@ class Relation if (!empty($range)) { // 查询关联数据 $data = $this->eagerlyManyToMany($model, [ - 'pivot.' . $foreignKey => [ + 'pivot.' . $localKey => [ 'in', $range, ], @@ -277,7 +277,7 @@ class Relation if (isset($result->$pk)) { $pk = $result->$pk; // 查询管理数据 - $data = $this->eagerlyManyToMany($model, ['pivot.' . $foreignKey => $pk], $relation, $subRelation); + $data = $this->eagerlyManyToMany($model, ['pivot.' . $localKey => $pk], $relation, $subRelation); // 关联数据封装 if (!isset($data[$pk])) { @@ -374,7 +374,7 @@ class Relation } } $set->pivot = new Pivot($pivot, $this->middle); - $data[$set->$foreignKey][] = $set; + $data[$pivot[$localKey]][] = $set; } return $data; }