From 8dc793d76c83a12ae0cb163460f9cf24a2eed054 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 14 Apr 2017 19:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=A4=9A=E6=80=81=E4=B8=80?= =?UTF-8?q?=E5=AF=B9=E5=A4=9A=20=E5=85=B3=E8=81=94=E8=A1=A8=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=95=B0=E6=8D=AE=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/MorphMany.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/think/model/relation/MorphMany.php b/library/think/model/relation/MorphMany.php index 4eee60fe..d37af144 100644 --- a/library/think/model/relation/MorphMany.php +++ b/library/think/model/relation/MorphMany.php @@ -152,6 +152,10 @@ class MorphMany extends Relation $this->morphType => $this->type, ], $relation, $subRelation, $closure); + if (!isset($data[$result->$pk])) { + $data[$result->$pk] = []; + } + foreach ($data[$result->$pk] as &$relationModel) { $relationModel->setParent(clone $result); $relationModel->isUpdate(true);