From 4780d194b52a5bf4aefba950f1c2e5c71c1ecf9b Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 7 Dec 2016 07:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E6=93=8D=E4=BD=9Cjoin=E8=87=AA=E8=BA=AB=E5=90=8E=E5=87=BA?= =?UTF-8?q?=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Builder.php | 3 +++ library/think/db/Query.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index f830d876..9c9ceb63 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -183,6 +183,9 @@ abstract class Builder $item = []; foreach ((array) $tables as $key => $table) { if (!is_numeric($key)) { + if (strpos($key, '@think')) { + $key = strstr($key, '@think', true); + } $key = $this->parseSqlTable($key); $item[] = $this->parseKey($key) . ' ' . $this->parseKey($table); } else { diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 6b6b5d10..1135a3d2 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -716,6 +716,9 @@ class Query } } if (isset($alias)) { + if (isset($this->options['alias'][$table])) { + $table = $table . '@think' . uniqid(); + } $table = [$table => $alias]; $this->alias($table); }