From 0674c774981517e48911eafc0f1102a8fe56a022 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 24 Oct 2016 14:15:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84view?= =?UTF-8?q?=E5=92=8Cjoin=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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index cf580b20..c78b17c1 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -671,7 +671,7 @@ class Query } else { $prefix = $this->prefix; $join = trim($join); - if ($prefix && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + if ($prefix && false === strpos($join, ' ') && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { $table = $this->getTable($join); $table = [$table => $join]; $this->alias($table); @@ -774,9 +774,11 @@ class Query if (is_array($join)) { // 支持数据表别名 list($table, $alias) = each($join); - } elseif ($prefix && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { + } elseif ($prefix && false === strpos($join, ' ') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) { $table = $this->getTable($join); $alias = $join; + } elseif (strpos($join, ' ')) { + list($table, $alias) = explode(' ', $join); } else { $alias = $join; }