Skip to content

Commit d135886

Browse files
committed
改进join方法的table参数解析
1 parent a26dd44 commit d135886

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/think/db/Query.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,24 @@ protected function getJoinTable($join, &$alias = null)
841841
if (false !== strpos($join, '(')) {
842842
// 使用子查询
843843
$table = $join;
844-
} elseif (strpos($join, ' ')) {
845-
// 使用别名
846-
list($table, $alias) = explode(' ', $join);
847844
} else {
848-
$table = $join;
845+
// 使用别名
846+
if (strpos($join, ' ')) {
847+
// 使用别名
848+
list($table, $alias) = explode(' ', $join);
849+
} else {
850+
$table = $join;
851+
if (false === strpos($join, '.')) {
852+
$alias = $join;
853+
}
854+
}
855+
856+
if ($this->prefix && false === strpos($table, '.') && 0 !== strpos($table, $this->prefix)) {
857+
$table = $this->getTable($table);
858+
}
849859
}
850860

851-
if (isset($alias) && $table != $alias) {
861+
if (!empty($alias) && $table != $alias) {
852862
$table = [$table => $alias];
853863
}
854864

0 commit comments

Comments
 (0)