if ($query_type == 'primary_fld') { // Gets table primary key $GLOBALS['dbi']->selectDb($db); $result = $GLOBALS['dbi']->query('SHOW KEYS FROM ' . PMA\libraries\Util::backquote($table) . ';'); $primary = ''; while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { // Backups the list of primary keys if ($row['Key_name'] == 'PRIMARY') { $primary .= $row['Column_name'] . ', '; } } // end while $GLOBALS['dbi']->freeResult($result); } if ($query_type == 'drop_tbl' || $query_type == 'empty_tbl' || $query_type == 'row_delete') { $default_fk_check_value = PMA\libraries\Util::handleDisableFKCheckInit(); } list($result, $rebuild_database_list, $reload_ret, $run_parts, $execute_query_later, $sql_query, $sql_query_views) = PMA_buildOrExecuteQueryForMulti($query_type, $selected, $db, $table, $views, isset($primary) ? $primary : null, isset($from_prefix) ? $from_prefix : null, isset($to_prefix) ? $to_prefix : null); //update the existed variable if (isset($reload_ret)) { $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) {
/** * 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 string html */ function 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) { // Handle disable/enable foreign key checks $default_fk_check = PMA\libraries\Util::handleDisableFKCheckInit(); // Handle remembered sorting order, only for single table query. // Handling is not required when it's a union query // (the parser never sets the 'union' key to 0). // Handling is also not required if we came from the "Sort by key" // drop-down. if (PMA_isRememberSortingOrder($analyzed_sql_results) && empty($analyzed_sql_results['union']) && !isset($_REQUEST['sort_by_key'])) { if (!isset($_SESSION['sql_from_query_box'])) { PMA_handleSortOrder($db, $table, $analyzed_sql_results, $sql_query); } else { unset($_SESSION['sql_from_query_box']); } } $displayResultsObject = new PMA\libraries\DisplayResults($GLOBALS['db'], $GLOBALS['table'], $goto, $sql_query); $displayResultsObject->setConfigParamsForDisplayTable(); // assign default full_sql_query $full_sql_query = $sql_query; // Do append a "LIMIT" clause? if (PMA_isAppendLimitClause($analyzed_sql_results)) { $full_sql_query = PMA_getSqlWithLimitClause($analyzed_sql_results); } $GLOBALS['reload'] = PMA_hasCurrentDbChanged($db); $GLOBALS['dbi']->selectDb($db); // Execute the query list($result, $num_rows, $unlim_num_rows, $profiling_results, $extra_data) = PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofile, $db, $table, isset($find_real_end) ? $find_real_end : null, isset($sql_query_for_bookmark) ? $sql_query_for_bookmark : null, isset($extra_data) ? $extra_data : null); // No rows returned -> move back to the calling page if (0 == $num_rows && 0 == $unlim_num_rows || $analyzed_sql_results['is_affected']) { $html_output = PMA_getQueryResponseForNoResultsReturned($analyzed_sql_results, $db, $table, isset($message_to_show) ? $message_to_show : null, $num_rows, $displayResultsObject, $extra_data, $pmaThemeImage, isset($result) ? $result : null, $sql_query, isset($complete_query) ? $complete_query : null); } else { // At least one row is returned -> displays a table with results $html_output = PMA_getQueryResponseForResultsReturned(isset($result) ? $result : null, $analyzed_sql_results, $db, $table, isset($message) ? $message : null, isset($sql_data) ? $sql_data : null, $displayResultsObject, $pmaThemeImage, $unlim_num_rows, $num_rows, isset($disp_query) ? $disp_query : null, isset($disp_message) ? $disp_message : null, $profiling_results, isset($query_type) ? $query_type : null, isset($selectedTables) ? $selectedTables : null, $sql_query, isset($complete_query) ? $complete_query : null); } // Handle disable/enable foreign key checks PMA\libraries\Util::handleDisableFKCheckCleanup($default_fk_check); return $html_output; }