diff --git a/lib/sqlparser/sqlparser.class.php b/lib/sqlparser/sqlparser.class.php index f671e68e50..9160c8f8b0 100644 --- a/lib/sqlparser/sqlparser.class.php +++ b/lib/sqlparser/sqlparser.class.php @@ -71,6 +71,26 @@ class sqlparser $this->isSelect = $this->statement instanceof PhpMyAdmin\SqlParser\Statements\SelectStatement === true; } + /** + * Parse columns. + * + * @access public + * @return void + */ + public function parseColumns() + { + $fields = array(); + foreach($this->statement->expr as $expr) + { + /* 获取查询数据后真正展示出来的列名 */ + $columnName = empty($expr->alias) ? $expr->column : $expr->alias; + + $fields[$columnName] = array('origin' => $expr->column, 'table' => $expr->table); + } + + return $fields; + } + /** * Parse tables. *