From 8271eea09186a9b350e9d7afc081afd93568716d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 1 Jun 2017 16:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BBelongsToMany=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/BelongsToMany.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/think/model/relation/BelongsToMany.php b/library/think/model/relation/BelongsToMany.php index 9eeb88dd..ec0eb440 100644 --- a/library/think/model/relation/BelongsToMany.php +++ b/library/think/model/relation/BelongsToMany.php @@ -162,7 +162,9 @@ class BelongsToMany extends Relation public function find($data = null) { $result = $this->buildQuery()->find($data); - $this->hydratePivot([$result]); + if ($result) { + $this->hydratePivot([$result]); + } return $result; }