From 224a9d5bb31f74d3d65a1d432d45a5826774b4f8 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 17 Mar 2017 19:03:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E4=B8=AD=E9=97=B4=E8=A1=A8?= =?UTF-8?q?=E5=90=8D=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/model/relation/BelongsToMany.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/think/model/relation/BelongsToMany.php b/library/think/model/relation/BelongsToMany.php index 4c768ba6..cd4bdfe6 100644 --- a/library/think/model/relation/BelongsToMany.php +++ b/library/think/model/relation/BelongsToMany.php @@ -44,10 +44,11 @@ class BelongsToMany extends Relation $this->model = $model; $this->foreignKey = $foreignKey; $this->localKey = $localKey; - if (false === strpos($table, '\\')) { - $this->middle = $table; - } else { + if (false !== strpos($table, '\\')) { $this->pivotName = $table; + $this->middle = basename(str_replace('\\', '/', $table)); + } else { + $this->middle = $table; } $this->query = (new $model)->db(); $this->pivot = $this->newPivot();