if (!PMA_DRIZZLE) { include_once './libraries/mysql_charsets.inc.php'; } if (!isset($mysql_charsets)) { $mysql_charsets = array(); $mysql_collations_flat = array(); } /** * Initializes the SQL parsing library. */ include_once SQL_PARSER_AUTOLOAD; // Loads closest context to this version. SqlParser\Context::loadClosest((PMA_DRIZZLE ? 'Drizzle' : 'MySql') . PMA_MYSQL_INT_VERSION); // Sets the default delimiter (if specified). if (!empty($_REQUEST['sql_delimiter'])) { SqlParser\Lexer::$DEFAULT_DELIMITER = $_REQUEST['sql_delimiter']; } // TODO: Set SQL modes too. /** * the PMA_List_Database class */ include_once './libraries/PMA.php'; $pma = new PMA(); $pma->userlink = $userlink; $pma->controllink = $controllink; /** * some resetting has to be done when switching servers */ if (isset($_SESSION['tmpval']['previous_server']) && $_SESSION['tmpval']['previous_server'] != $GLOBALS['server']) { unset($_SESSION['tmpval']['navi_limit_offset']); }
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';