修正Relation类 改进Route类的group方法

This commit is contained in:
thinkphp
2016-05-11 22:03:26 +08:00
parent 15e01901fb
commit cbd8ea477d
3 changed files with 143 additions and 54 deletions

View File

@@ -85,9 +85,9 @@ class Relation
break;
case self::BELONGS_TO_MANY:
// 关联查询
$pk = $this->parent->getPk();
$condition['pivot.' . $foreignKey] = $this->parent->$pk;
$result = $this->belongsToManyQuery($relation, $this->middle, $foreignKey, $localKey, $condition)->select();
$pk = $this->parent->getPk();
$condition['pivot.' . $localKey] = $this->parent->$pk;
$result = $this->belongsToManyQuery($relation, $this->middle, $foreignKey, $localKey, $condition)->select();
foreach ($result as $set) {
$pivot = [];
foreach ($set->toArray() as $key => $val) {