Skip to content

Commit

Permalink
改进Query类的view和join方法
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Oct 24, 2016
1 parent 4e8467b commit 0674c77
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions library/think/db/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public function join($join, $condition = null, $type = 'INNER')
} else {
$prefix = $this->prefix;
$join = trim($join);
if ($prefix && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) {
if ($prefix && false === strpos($join, ' ') && false === strpos($join, '(') && false === strpos($join, '.') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) {
$table = $this->getTable($join);
$table = [$table => $join];
$this->alias($table);
Expand Down Expand Up @@ -774,9 +774,11 @@ public function view($join, $field = true, $on = null, $type = 'INNER')
if (is_array($join)) {
// 支持数据表别名
list($table, $alias) = each($join);
} elseif ($prefix && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) {
} elseif ($prefix && false === strpos($join, ' ') && 0 !== strpos($join, $prefix) && 0 !== strpos($join, '__')) {
$table = $this->getTable($join);
$alias = $join;
} elseif (strpos($join, ' ')) {
list($table, $alias) = explode(' ', $join);
} else {
$alias = $join;
}
Expand Down

0 comments on commit 0674c77

Please sign in to comment.