修正hasMany关联

This commit is contained in:
thinkphp
2017-09-11 18:29:14 +08:00
parent 1b65f2ec41
commit e2d2f37930

View File

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