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); }