foreach ($parser->statements[0]->from as $from) { if (!empty($from->table) && !empty($from->alias)) { $aliases[$from->alias] = $from->table; // We remove the alias of the table because they are going to // be replaced anyway. $from->alias = null; $from->expr = null; // Force rebuild. } } // Rebuilding the SELECT and FROM clauses. $replaces = array(array('FROM', 'FROM ' . SqlParser\Components\ExpressionArray::build($parser->statements[0]->from))); // Checking if the WHERE clause has to be replaced. if (!empty($where_clause) && is_array($where_clause)) { $replaces[] = array('WHERE', 'WHERE (' . implode(') OR (', $where_clause) . ')'); } // Preparing to remove the LIMIT clause. $replaces[] = array('LIMIT', ''); // Replacing the clauses. $sql_query = SqlParser\Utils\Query::replaceClauses($parser->statements[0], $parser->list, $replaces); // Removing the aliases by finding the alias followed by a dot. $tokens = SqlParser\Lexer::getTokens($sql_query); foreach ($aliases as $alias => $table) { $tokens = SqlParser\Utils\Tokens::replaceTokens($tokens, array(array('value_str' => $alias), array('type' => SqlParser\Token::TYPE_OPERATOR, 'value_str' => '.')), array()); } $sql_query = SqlParser\TokensList::build($tokens); } echo PMA_Util::getMessage(PMA_Message::success()); } $export_type = 'table'; require_once 'libraries/display_export.inc.php';
$parser->statements[0], $parser->list, $replaces ); // Removing the aliases by finding the alias followed by a dot. $tokens = SqlParser\Lexer::getTokens($sql_query); foreach ($aliases as $alias => $table) { $tokens = SqlParser\Utils\Tokens::replaceTokens( $tokens, array( array( 'value_str' => $alias, ), array( 'type' => SqlParser\Token::TYPE_OPERATOR, 'value_str' => '.', ) ), array( new SqlParser\Token($table), new SqlParser\Token('.', SqlParser\Token::TYPE_OPERATOR) ) ); } $sql_query = SqlParser\TokensList::build($tokens); } echo PMA\libraries\Util::getMessage(PMA\libraries\Message::success()); } require_once 'libraries/display_export.lib.php';