From e3ec75d001eec2067d84e4e91907d226d02c2fe2 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sun, 9 Oct 2016 12:08:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BB=E7=9A=84table?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=92=8Calias=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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index c277c9d9..2e37e1a3 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -1046,7 +1046,8 @@ class Query } } elseif (strpos($table, ' ')) { list($table, $alias) = explode(' ', $table); - $this->alias([$table => $alias]); + $table = [$table => $alias]; + $this->alias($table); } } else { $tables = $table; @@ -1189,7 +1190,11 @@ class Query $this->options['alias'][$key] = $val; } } else { - $table = isset($this->options['table']) ? $this->options['table'] : $this->getTable(); + if (isset($this->options['table'])) { + $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table']; + } else { + $table = $this->getTable(); + } $this->options['alias'][$table] = $alias; }