/** * Function to handle all aspects relating to executing the query * * @param array $analyzed_sql_results analyzed sql results * @param String $full_sql_query full sql query * @param boolean $is_gotofile whether to go to a file * @param String $db current database * @param String $table current table * @param boolean $find_real_end whether to find the real end * @param String $sql_query_for_bookmark sql query to be stored as bookmark * @param array $extra_data extra data * * @return mixed */ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofile, $db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data) { $response = PMA\libraries\Response::getInstance(); $response->getHeader()->getMenu()->setTable($table); // Only if we ask to see the php code if (isset($GLOBALS['show_as_php'])) { $result = null; $num_rows = 0; $unlim_num_rows = 0; } else { // If we don't ask to see the php code if (isset($_SESSION['profiling']) && PMA\libraries\Util::profilingSupported()) { $GLOBALS['dbi']->query('SET PROFILING=1;'); } list($result, $GLOBALS['querytime']) = PMA_executeQueryAndMeasureTime($full_sql_query); // Displays an error message if required and stop parsing the script $error = $GLOBALS['dbi']->getError(); if ($error && $GLOBALS['cfg']['IgnoreMultiSubmitErrors']) { $extra_data['error'] = $error; } elseif ($error) { PMA_handleQueryExecuteError($is_gotofile, $error, $full_sql_query); } // If there are no errors and bookmarklabel was given, // store the query as a bookmark if (!empty($_POST['bkm_label']) && !empty($sql_query_for_bookmark)) { $cfgBookmark = PMA_Bookmark_getParams(); PMA_storeTheQueryAsBookmark($db, $cfgBookmark['user'], $sql_query_for_bookmark, $_POST['bkm_label'], isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null); } // end store bookmarks // Gets the number of rows affected/returned // (This must be done immediately after the query because // mysql_affected_rows() reports about the last query done) $num_rows = PMA_getNumberOfRowsAffectedOrChanged($analyzed_sql_results['is_affected'], $result); // Grabs the profiling results if (isset($_SESSION['profiling']) && PMA\libraries\Util::profilingSupported()) { $profiling_results = $GLOBALS['dbi']->fetchResult('SHOW PROFILE;'); } $justBrowsing = PMA_isJustBrowsing($analyzed_sql_results, isset($find_real_end) ? $find_real_end : null); $unlim_num_rows = PMA_countQueryResults($num_rows, $justBrowsing, $db, $table, $analyzed_sql_results); PMA_cleanupRelations(isset($db) ? $db : '', isset($table) ? $table : '', isset($_REQUEST['dropped_column']) ? $_REQUEST['dropped_column'] : null, isset($_REQUEST['purge']) ? $_REQUEST['purge'] : null); if (isset($_REQUEST['dropped_column']) && mb_strlen($db) && mb_strlen($table)) { // to refresh the list of indexes (Ajax mode) $extra_data['indexes_list'] = PMA\libraries\Index::getHtmlForIndexes($table, $db); } } return array($result, $num_rows, $unlim_num_rows, isset($profiling_results) ? $profiling_results : null, $extra_data); }