From 64ea8511cd5f5564627d6d0d27df441d96c5ffdc Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 26 Oct 2018 16:29:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/BelongsToMany.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/think/model/relation/BelongsToMany.php b/library/think/model/relation/BelongsToMany.php index ab1d8dc1..a41c45ce 100644 --- a/library/think/model/relation/BelongsToMany.php +++ b/library/think/model/relation/BelongsToMany.php @@ -365,9 +365,11 @@ class BelongsToMany extends Relation */ public function getRelationCountQuery($closure, &$name = null) { - $return = call_user_func_array($closure, [ & $this->query]); - if ($return && is_string($return)) { - $name = $return; + if ($closure) { + $return = call_user_func_array($closure, [ & $this->query]); + if ($return && is_string($return)) { + $name = $return; + } } return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [