protected function processFromExpression(&$parseInfo)
{
$res = array();
// exchange the join types (join_type is save now, saved_join_type holds the next one)
$parseInfo['join_type'] = $parseInfo['saved_join_type'];
// initialized with JOIN
$parseInfo['saved_join_type'] = $parseInfo['next_join_type'] ? $parseInfo['next_join_type'] : 'JOIN';
// we have a reg_expr, so we have to parse it
if ($parseInfo['ref_expr'] !== false) {
$unparsed = $this->splitSQLIntoTokens($parseInfo['ref_expr']);
// here we can get a comma separated list
foreach ($unparsed as $k => $v) {
if ($this->isCommaToken($v)) {
$unparsed[$k] = "";
}
}
if ($parseInfo['ref_type'] === 'USING') {
// unparsed has only one entry, the column list
$ref = $this->processColumnList($this->removeParenthesisFromStart($unparsed[0]));
$ref = array(array('expr_type' => ExpressionType::COLUMN_LIST, 'base_expr' => $unparsed[0], 'sub_tree' => $ref));
} else {
$ref = $this->processExpressionList($unparsed);
}
$parseInfo['ref_expr'] = empty($ref) ? false : $ref;
}
// there is an expression, we have to parse it
if (substr(trim($parseInfo['table']), 0, 1) == '(') {
$parseInfo['expression'] = $this->removeParenthesisFromStart($parseInfo['table']);
if (preg_match("/^\\s*select/i", $parseInfo['expression'])) {
$parseInfo['sub_tree'] = $this->processSQLDefault($parseInfo['expression']);
$res['expr_type'] = ExpressionType::SUBQUERY;
} else {
$tmp = $this->splitSQLIntoTokens($parseInfo['expression']);
$unionProcessor = new UnionProcessor();
$unionQueries = $unionProcessor->process($tmp);
// If there was no UNION or UNION ALL in the query, then the query is
// stored at $queries[0].
if (!empty($unionQueries) && !UnionProcessor::isUnion($unionQueries)) {
$sub_tree = $this->process($unionQueries[0]);
} else {
$sub_tree = $unionQueries;
}
$parseInfo['sub_tree'] = $sub_tree;
$res['expr_type'] = ExpressionType::TABLE_EXPRESSION;
}
} else {
$res['expr_type'] = ExpressionType::TABLE;
$res['table'] = $parseInfo['table'];
$res['no_quotes'] = $this->revokeQuotation($parseInfo['table']);
}
$res['alias'] = $parseInfo['alias'];
$res['hints'] = $parseInfo['hints'];
$res['join_type'] = $parseInfo['join_type'];
$res['ref_type'] = $parseInfo['ref_type'];
$res['ref_clause'] = $parseInfo['ref_expr'];
$res['base_expr'] = trim($parseInfo['expression']);
$res['sub_tree'] = $parseInfo['sub_tree'];
return $res;
}