改进hasWhere查询的数据重复问题

This commit is contained in:
thinkphp
2017-11-24 17:22:58 +08:00
parent b69e64a521
commit 5706ed7e44
2 changed files with 2 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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);
}