mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
简化join方法
This commit is contained in:
@@ -663,38 +663,19 @@ class Query
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$prefix = $this->prefix;
|
|
||||||
// 传入的表名为数组
|
// 传入的表名为数组
|
||||||
if (is_array($join)) {
|
if (is_array($join)) {
|
||||||
if (count($join) > 1) {
|
|
||||||
$prefix = array_pop($join);
|
|
||||||
}
|
|
||||||
if (0 !== $key = key($join)) {
|
if (0 !== $key = key($join)) {
|
||||||
// 设置了键名则键名为表名,键值作为表的别名
|
// 设置了键名则键名为表名,键值作为表的别名
|
||||||
$table = $key;
|
$table = $key;
|
||||||
if (false === strpos($table, '.')) {
|
|
||||||
$table = $prefix . $table;
|
|
||||||
}
|
|
||||||
$alias = array_shift($join);
|
$alias = array_shift($join);
|
||||||
$this->alias([$table => $alias]);
|
$this->alias([$table => $alias]);
|
||||||
$table = [$table => $alias];
|
$table = [$table => $alias];
|
||||||
} else {
|
} else {
|
||||||
$table = array_shift($join);
|
$table = array_shift($join);
|
||||||
if (false === strpos($table, '.')) {
|
|
||||||
$table = $prefix . $table;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$join = trim($join);
|
$table = trim($join);
|
||||||
if (0 === strpos($join, '__')) {
|
|
||||||
$table = $this->parseSqlTable($join);
|
|
||||||
} elseif (false === strpos($join, '(') && false === strpos($join, '.') && !empty($prefix) && 0 !== strpos($join, $prefix)) {
|
|
||||||
// 传入的表名中不带有'('并且不以默认的表前缀开头时加上默认的表前缀
|
|
||||||
$table = $prefix . $join;
|
|
||||||
} else {
|
|
||||||
$table = $join;
|
|
||||||
}
|
|
||||||
if (strpos($table, ' ')) {
|
if (strpos($table, ' ')) {
|
||||||
list($table, $alias) = explode(' ', $table);
|
list($table, $alias) = explode(' ', $table);
|
||||||
$this->alias([$table => $alias]);
|
$this->alias([$table => $alias]);
|
||||||
|
|||||||
Reference in New Issue
Block a user