mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
改进table方法的解析
This commit is contained in:
@@ -173,29 +173,25 @@ abstract class Builder
|
|||||||
/**
|
/**
|
||||||
* table分析
|
* table分析
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param mixed $table
|
* @param mixed $tables
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseTable($tables, $options = [])
|
protected function parseTable($tables, $options = [])
|
||||||
{
|
{
|
||||||
if (is_array($tables)) {
|
if (is_string($tables)) {
|
||||||
// 支持别名定义
|
$tables = (array) $tables;
|
||||||
foreach ($tables as $table => $alias) {
|
}
|
||||||
$array[] = !is_numeric($table) ?
|
$item = [];
|
||||||
$this->parseKey($table) . ' ' . $this->parseKey($alias) :
|
foreach ($tables as $table) {
|
||||||
$this->parseKey($alias);
|
$table = $this->parseSqlTable($table);
|
||||||
}
|
if (isset($options['alias'][$table])) {
|
||||||
$tables = implode(',', $array);
|
$item[] = $this->parseKey($table) . ' ' . $this->parseKey($options['alias'][$table]);
|
||||||
} elseif (is_string($tables)) {
|
|
||||||
$tables = $this->parseSqlTable($tables);
|
|
||||||
if (isset($options['alias'][$tables])) {
|
|
||||||
$tables = $this->parseKey($tables) . ' ' . $this->parseKey($options['alias'][$tables]);
|
|
||||||
} else {
|
} else {
|
||||||
$tables = $this->parseKey($tables);
|
$item[] = $this->parseKey($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $tables;
|
return implode(',', $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1049,6 +1049,17 @@ class Query
|
|||||||
list($table, $alias) = explode(' ', $table);
|
list($table, $alias) = explode(' ', $table);
|
||||||
$this->alias([$table => $alias]);
|
$this->alias([$table => $alias]);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$tables = $table;
|
||||||
|
$table = [];
|
||||||
|
foreach ($tables as $key => $val) {
|
||||||
|
if (is_numeric($key)) {
|
||||||
|
$table[] = $val;
|
||||||
|
} else {
|
||||||
|
$this->alias([$key => $val]);
|
||||||
|
$table[] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->options['table'] = $table;
|
$this->options['table'] = $table;
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
Reference in New Issue
Block a user