改进join自关联查询

This commit is contained in:
thinkphp
2018-01-28 22:44:25 +08:00
parent b72caee28b
commit 34875308ae
2 changed files with 3 additions and 14 deletions

View File

@@ -707,8 +707,7 @@ class Query
{
// 传入的表名为数组
if (is_array($join)) {
$table = key($join);
$alias = current($join);
$table = $join;
} else {
$join = trim($join);
if (false !== strpos($join, '(')) {
@@ -729,16 +728,9 @@ class Query
$table = $this->getTable($table);
}
}
}
if (isset($alias) && $table != $alias) {
if (isset($this->options['alias'][$table])) {
$table = $table . '@think' . uniqid();
} elseif ($this->gettable() == $table) {
$table = $table . '@think' . uniqid();
if (isset($alias) && $table != $alias) {
$table = [$table => $alias];
}
$table = [$table => $alias];
$this->alias($table);
}
return $table;
}