/** * Parses and analyzes the given SQL query. * * @param string $sql_query SQL query * @param string $db DB name * * @return mixed */ function PMA_parseAndAnalyze($sql_query, $db = null) { if ($db === null && !empty($GLOBALS['db'])) { $db = $GLOBALS['db']; } include_once 'libraries/parse_analyze.lib.php'; list($analyzed_sql_results, , ) = PMA_parseAnalyze($sql_query, $db); return $analyzed_sql_results; }
$reload = $reload_ret; } if ($query_type == 'drop_tbl') { if (!empty($sql_query)) { $sql_query .= ';'; } elseif (!empty($sql_query_views)) { $sql_query = $sql_query_views . ';'; unset($sql_query_views); } } if ($execute_query_later) { /** * Parse and analyze the query */ include_once 'libraries/parse_analyze.lib.php'; list($analyzed_sql_results, $db, $table) = PMA_parseAnalyze($sql_query, $db); // @todo: possibly refactor extract($analyzed_sql_results); PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, false, $db, $table, null, null, null, null, null, null, $goto, $pmaThemeImage, null, null, $query_type, $sql_query, $selected, null); } elseif (!$run_parts) { $GLOBALS['dbi']->selectDb($db); $result = $GLOBALS['dbi']->tryQuery($sql_query); if ($result && !empty($sql_query_views)) { $sql_query .= ' ' . $sql_query_views . ';'; $result = $GLOBALS['dbi']->tryQuery($sql_query_views); unset($sql_query_views); } if (!$result) { $message = Message::error($GLOBALS['dbi']->getError()); } }
/** * Function to display table browse for selected columns * * @param string $goto goto page url * @param string $pmaThemeImage URI of the pma theme image * * @return void */ protected function displayTableBrowseForSelectedColumns($goto, $pmaThemeImage) { $GLOBALS['active_page'] = 'sql.php'; $fields = array(); foreach ($_REQUEST['selected_fld'] as $sval) { $fields[] = Util::backquote($sval); } $sql_query = sprintf('SELECT %s FROM %s.%s', implode(', ', $fields), Util::backquote($this->db), Util::backquote($this->table)); // Parse and analyze the query $db =& $this->db; include_once 'libraries/parse_analyze.lib.php'; list($analyzed_sql_results, $db, ) = PMA_parseAnalyze($sql_query, $db); // @todo: possibly refactor extract($analyzed_sql_results); include_once 'libraries/sql.lib.php'; $this->response->addHTML(PMA_executeQueryAndGetQueryResponse(isset($analyzed_sql_results) ? $analyzed_sql_results : '', false, $this->db, $this->table, null, null, null, null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, null, null)); }
/** * Do selection action * * @return void */ public function doSelectionAction() { /** * Selection criteria have been submitted -> do the work */ $sql_query = $this->_buildSqlQuery(); /** * Add this to ensure following procedures included running correctly. */ $db = $this->db; $table = $this->table; /** * Parse and analyze the query */ include_once 'libraries/parse_analyze.lib.php'; list($analyzed_sql_results, , ) = PMA_parseAnalyze($sql_query, $db); // @todo: possibly refactor extract($analyzed_sql_results); PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, false, $this->db, $this->table, null, null, null, null, null, null, $GLOBALS['goto'], $GLOBALS['pmaThemeImage'], null, null, null, $sql_query, null, null); }
/** * Function to execute the query and send the response * * @param array $analyzed_sql_results analysed sql results * @param bool $is_gotofile whether goto file or not * @param string $db current database * @param string $table current table * @param bool|null $find_real_end whether to find real end or not * @param string $sql_query_for_bookmark the sql query to be stored as bookmark * @param array|null $extra_data extra data * @param string $message_to_show message to show * @param string $message message * @param array|null $sql_data sql data * @param string $goto goto page url * @param string $pmaThemeImage uri of the PMA theme image * @param string $disp_query display query * @param string $disp_message display message * @param string $query_type query type * @param string $sql_query sql query * @param array|null $selectedTables array of table names selected from the * database structure page, for an action * like check table, optimize table, * analyze table or repair table * @param string $complete_query complete query * * @return void */ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, $is_gotofile, $db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data, $message_to_show, $message, $sql_data, $goto, $pmaThemeImage, $disp_query, $disp_message, $query_type, $sql_query, $selectedTables, $complete_query) { if ($analyzed_sql_results == null) { // Parse and analyze the query include_once 'libraries/parse_analyze.lib.php'; list($analyzed_sql_results, $db, $table) = PMA_parseAnalyze($sql_query, $db); // @todo: possibly refactor extract($analyzed_sql_results); } $html_output = PMA_executeQueryAndGetQueryResponse($analyzed_sql_results, $is_gotofile, $db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data, $message_to_show, $message, $sql_data, $goto, $pmaThemeImage, $disp_query, $disp_message, $query_type, $sql_query, $selectedTables, $complete_query); $response = PMA\libraries\Response::getInstance(); $response->addHTML($html_output); }