/**
 * Get HTML for display indexes
 *
 * @return string $html_output
 */
function PMA_getHtmlForDisplayIndexes()
{
    $html_output = '<div id="index_div" class="ajax';
    if ($GLOBALS['cfg']['InitialSlidersState'] != 'disabled') {
        $html_output .= ' print_ignore';
    }
    $html_output .= '" >';
    $html_output .= PMA_Util::getDivForSliderEffect('indexes', __('Indexes'));
    $html_output .= PMA_Index::getHtmlForIndexes($GLOBALS['table'], $GLOBALS['db']);
    $html_output .= '<fieldset class="tblFooters print_ignore" style="text-align: ' . 'left;"><form action="tbl_indexes.php" method="post">';
    $html_output .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
    $html_output .= sprintf(__('Create an index on &nbsp;%s&nbsp;columns'), '<input type="number" name="added_fields" value="1" ' . 'min="1" required="required" />');
    $html_output .= '<input type="hidden" name="create_index" value="1" />' . '<input class="add_index ajax"' . ' type="submit" value="' . __('Go') . '" />';
    $html_output .= '</form>' . '</fieldset>' . '</div>' . '</div>';
    return $html_output;
}
$response->addHTML('<div id="structure-action-links">');
if ($tbl_is_view) {
    $response->addHTML(PMA_getHtmlForEditView($url_params));
}
$response->addHTML(PMA_getHtmlForOptionalActionLinks($url_query, $tbl_is_view, $db_is_system_schema));
$response->addHTML('</div>');
if (!$tbl_is_view && !$db_is_system_schema) {
    $response->addHTML('<br />');
    $response->addHTML(PMA_getHtmlForAddColumn($columns_list));
}
/**
 * Displays indexes
 */
if (!$tbl_is_view && !$db_is_system_schema && 'ARCHIVE' != $tbl_storage_engine) {
    //return the list of index
    $response->addJSON('indexes_list', PMA_Index::getHtmlForIndexes($GLOBALS['table'], $GLOBALS['db']));
    $response->addHTML(PMA_getHtmlForDisplayIndexes());
}
/**
 * Displays Space usage and row statistics
 */
// BEGIN - Calc Table Space
// Get valid statistics whatever is the table type
if ($cfg['ShowStats']) {
    //get table stats in HTML format
    $tablestats = PMA_getHtmlForDisplayTableStats($showtable, $table_info_num_rows, $tbl_is_view, $db_is_system_schema, $tbl_storage_engine, $url_query, $tbl_collation);
    //returning the response in JSON format to be used by Ajax
    $response->addJSON('tableStat', $tablestats);
    $response->addHTML($tablestats);
}
// END - Calc Table Space
            echo '</td>' . "\n";
        }
        echo '    <td>';
        if (isset($comments[$column_name])) {
            echo htmlspecialchars($comments[$column_name]);
        }
        echo '</td>' . "\n";
        if ($cfgRelation['mimework']) {
            $mime_map = PMA_getMIME($db, $table, true);
            echo '    <td>';
            if (isset($mime_map[$column_name])) {
                echo htmlspecialchars(str_replace('_', '/', $mime_map[$column_name]['mimetype']));
            }
            echo '</td>' . "\n";
        }
        echo '</tr>';
    }
    // end foreach
    $count++;
    echo '</table>';
    // display indexes information
    if (count(PMA_Index::getFromTable($table, $db)) > 0) {
        echo PMA_Index::getHtmlForIndexes($table, $db, true);
    }
    echo '</div>';
}
//ends main while
/**
 * Displays the footer
 */
echo PMA_Util::getButton();
Exemple #4
0
/**
 * 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_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_Util::profilingSupported()) {
            $GLOBALS['dbi']->query('SET PROFILING=1;');
        }
        $result = PMA_executeQueryAndStoreResults($full_sql_query);
        // Displays an error message if required and stop parsing the script
        $error = $GLOBALS['dbi']->getError();
        if ($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_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_Index::getHtmlForIndexes($table, $db);
        }
    }
    return array($result, $num_rows, $unlim_num_rows, isset($profiling_results) ? $profiling_results : null, $extra_data);
}
 * and moves back to "tbl_sql.php"
 */
if (isset($_REQUEST['do_save_data'])) {
    $error = false;
    $sql_query = $GLOBALS['dbi']->getTable($db, $table)->getSqlQueryForIndexCreateOrEdit($index, $error);
    // If there is a request for SQL previewing.
    if (isset($_REQUEST['preview_sql'])) {
        PMA_Response::getInstance()->addJSON('sql_data', PMA\Template::get('preview_sql')->render(array('query_data' => $sql_query)));
    } elseif (!$error) {
        $GLOBALS['dbi']->query($sql_query);
        if ($GLOBALS['is_ajax_request'] == true) {
            $message = PMA_Message::success(__('Table %1$s has been altered successfully.'));
            $message->addParam($table);
            $response = PMA_Response::getInstance();
            $response->addJSON('message', PMA_Util::getMessage($message, $sql_query, 'success'));
            $response->addJSON('index_table', PMA_Index::getHtmlForIndexes($table, $db));
        } else {
            include 'tbl_structure.php';
        }
    } else {
        $response = PMA_Response::getInstance();
        $response->isSuccess(false);
        $response->addJSON('message', $error);
    }
    exit;
}
// end builds the new index
/**
 * Display the form to edit/create an index
 */
require_once 'libraries/tbl_info.inc.php';