mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 23:52:49 +08:00
修正Query的join方法
This commit is contained in:
@@ -442,8 +442,12 @@ abstract class Builder
|
|||||||
list($table, $type, $on) = $item;
|
list($table, $type, $on) = $item;
|
||||||
$condition = [];
|
$condition = [];
|
||||||
foreach ((array) $on as $val) {
|
foreach ((array) $on as $val) {
|
||||||
|
if (strpos($val, '=')) {
|
||||||
list($val1, $val2) = explode('=', $val, 2);
|
list($val1, $val2) = explode('=', $val, 2);
|
||||||
$condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options);
|
$condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options);
|
||||||
|
} else {
|
||||||
|
$condition[] = $val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = $this->parseTable($table, $options);
|
$table = $this->parseTable($table, $options);
|
||||||
|
|||||||
@@ -666,22 +666,25 @@ class Query
|
|||||||
$prefix = $this->prefix;
|
$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, '.')) {
|
||||||
if (count($join)) {
|
|
||||||
// 有设置第二个元素则把第二元素作为表前缀
|
|
||||||
$table = (string) current($join) . $table;
|
|
||||||
} elseif (false === strpos($table, '.')) {
|
|
||||||
// 加上默认的表前缀
|
|
||||||
$table = $prefix . $table;
|
$table = $prefix . $table;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$join = trim($join);
|
$join = trim($join);
|
||||||
if (0 === strpos($join, '__')) {
|
if (0 === strpos($join, '__')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user