Skip to content

Commit

Permalink
改进join方法的table参数解析
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Nov 23, 2018
1 parent a26dd44 commit d135886
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/think/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,24 @@ protected function getJoinTable($join, &$alias = null)
if (false !== strpos($join, '(')) {
// 使用子查询
$table = $join;
} elseif (strpos($join, ' ')) {
// 使用别名
list($table, $alias) = explode(' ', $join);
} else {
$table = $join;
// 使用别名
if (strpos($join, ' ')) {
// 使用别名
list($table, $alias) = explode(' ', $join);
} else {
$table = $join;
if (false === strpos($join, '.')) {
$alias = $join;
}
}

if ($this->prefix && false === strpos($table, '.') && 0 !== strpos($table, $this->prefix)) {
$table = $this->getTable($table);
}
}

if (isset($alias) && $table != $alias) {
if (!empty($alias) && $table != $alias) {
$table = [$table => $alias];
}

Expand Down

0 comments on commit d135886

Please sign in to comment.