改进Query类的table方法和alias方法

This commit is contained in:
thinkphp
2016-10-09 12:08:49 +08:00
parent 6f9fc912df
commit e3ec75d001

View File

@@ -1046,7 +1046,8 @@ class Query
} }
} elseif (strpos($table, ' ')) { } elseif (strpos($table, ' ')) {
list($table, $alias) = explode(' ', $table); list($table, $alias) = explode(' ', $table);
$this->alias([$table => $alias]); $table = [$table => $alias];
$this->alias($table);
} }
} else { } else {
$tables = $table; $tables = $table;
@@ -1189,7 +1190,11 @@ class Query
$this->options['alias'][$key] = $val; $this->options['alias'][$key] = $val;
} }
} else { } else {
$table = isset($this->options['table']) ? $this->options['table'] : $this->getTable(); if (isset($this->options['table'])) {
$table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table'];
} else {
$table = $this->getTable();
}
$this->options['alias'][$table] = $alias; $this->options['alias'][$table] = $alias;
} }