改进一对多with关联查询的field支持

This commit is contained in:
thinkphp
2017-11-24 17:36:43 +08:00
parent 5706ed7e44
commit 6381d65bb3

View File

@@ -77,7 +77,7 @@ class HasMany extends Relation
} }
if (!empty($range)) { if (!empty($range)) {
$data = $this->eagerlyOneToMany(new $this->model, [ $data = $this->eagerlyOneToMany($this->query, [
$this->foreignKey => [ $this->foreignKey => [
'in', 'in',
$range, $range,
@@ -114,7 +114,7 @@ class HasMany extends Relation
$localKey = $this->localKey; $localKey = $this->localKey;
if (isset($result->$localKey)) { if (isset($result->$localKey)) {
$data = $this->eagerlyOneToMany(new $this->model, [$this->foreignKey => $result->$localKey], $relation, $subRelation, $closure); $data = $this->eagerlyOneToMany($this->query, [$this->foreignKey => $result->$localKey], $relation, $subRelation, $closure);
// 关联数据封装 // 关联数据封装
if (!isset($data[$result->$localKey])) { if (!isset($data[$result->$localKey])) {
$data[$result->$localKey] = []; $data[$result->$localKey] = [];