From 2c15118f6075bf0d27c65fb5b444c09ffb6292ff Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 21 Oct 2016 23:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84join?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index e5c9b978..57a1fc50 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -670,14 +670,17 @@ class Query } } else { $prefix = $this->prefix; - $table = trim($join); - if ($prefix && false === strpos($table, '(') && false === strpos($table, '.') && 0 !== strpos($table, $prefix) && 0 !== strpos($table, '__')) { - $table = $this->getTable($table); - } - if (strpos($table, ' ') && !strpos($table, ')')) { - list($table, $alias) = explode(' ', $table); + $join = trim($join); + if ($prefix && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + $table = $this->getTable($join); + $table = [$table => $join]; + $this->alias($table); + } elseif (strpos($join, ' ') && !strpos($join, ')')) { + list($table, $alias) = explode(' ', $join); $table = [$table => $alias]; $this->alias($table); + } else { + $table = $join; } } $this->options['join'][] = [$table, strtoupper($type), $condition];