mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进join自关联查询
This commit is contained in:
@@ -207,9 +207,6 @@ abstract class Builder
|
|||||||
$item = [];
|
$item = [];
|
||||||
foreach ((array) $tables as $key => $table) {
|
foreach ((array) $tables as $key => $table) {
|
||||||
if (!is_numeric($key)) {
|
if (!is_numeric($key)) {
|
||||||
if (strpos($key, '@think')) {
|
|
||||||
$key = strstr($key, '@think', true);
|
|
||||||
}
|
|
||||||
$key = $this->parseSqlTable($key);
|
$key = $this->parseSqlTable($key);
|
||||||
$item[] = $this->parseKey($key) . ' ' . (isset($options['alias'][$table]) ? $this->parseKey($options['alias'][$table]) : $this->parseKey($table));
|
$item[] = $this->parseKey($key) . ' ' . (isset($options['alias'][$table]) ? $this->parseKey($options['alias'][$table]) : $this->parseKey($table));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -707,8 +707,7 @@ class Query
|
|||||||
{
|
{
|
||||||
// 传入的表名为数组
|
// 传入的表名为数组
|
||||||
if (is_array($join)) {
|
if (is_array($join)) {
|
||||||
$table = key($join);
|
$table = $join;
|
||||||
$alias = current($join);
|
|
||||||
} else {
|
} else {
|
||||||
$join = trim($join);
|
$join = trim($join);
|
||||||
if (false !== strpos($join, '(')) {
|
if (false !== strpos($join, '(')) {
|
||||||
@@ -729,16 +728,9 @@ class Query
|
|||||||
$table = $this->getTable($table);
|
$table = $this->getTable($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (isset($alias) && $table != $alias) {
|
||||||
if (isset($alias) && $table != $alias) {
|
$table = [$table => $alias];
|
||||||
if (isset($this->options['alias'][$table])) {
|
|
||||||
$table = $table . '@think' . uniqid();
|
|
||||||
} elseif ($this->gettable() == $table) {
|
|
||||||
$table = $table . '@think' . uniqid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = [$table => $alias];
|
|
||||||
$this->alias($table);
|
|
||||||
}
|
}
|
||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user