改进parseTable方法和parseJoin 关联预载入支持hasOne自关联

This commit is contained in:
thinkphp
2016-10-08 21:53:27 +08:00
parent b810c9a3ca
commit 6f9fc912df
2 changed files with 29 additions and 15 deletions

View File

@@ -180,12 +180,17 @@ abstract class Builder
protected function parseTable($tables, $options = [])
{
$item = [];
foreach ((array) $tables as $table) {
$table = $this->parseSqlTable($table);
if (isset($options['alias'][$table])) {
$item[] = $this->parseKey($table) . ' ' . $this->parseKey($options['alias'][$table]);
foreach ((array) $tables as $key => $table) {
if (!is_numeric($key)) {
$key = $this->parseSqlTable($key);
$item[] = $this->parseKey($key) . ' ' . $this->parseKey($table);
} else {
$item[] = $this->parseKey($table);
$table = $this->parseSqlTable($table);
if (isset($options['alias'][$table])) {
$item[] = $this->parseKey($table) . ' ' . $this->parseKey($options['alias'][$table]);
} else {
$item[] = $this->parseKey($table);
}
}
}
return implode(',', $item);