getHeader(); $scripts = $header->getScripts(); $scripts->addFile('tbl_structure.js'); $scripts->addFile('indexes.js'); /** * Handle column moving */ if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $response->isAjax() ) { PMA_moveColumns($db, $table); exit; } /** * A click on Change has been made for one column */ if (isset($_REQUEST['change_column'])) { PMA_displayHtmlForColumnChange($db, $table, null, 'tbl_structure.php'); exit; } /** * Modifications have been submitted -> updates the table */ if (isset($_REQUEST['do_save_data'])) { $regenerate = PMA_updateColumns($db, $table); if ($regenerate) { // This happens when updating failed // @todo: do something appropriate } else { // continue to show the table's structure unset($_REQUEST['selected']); } } /** * handle multiple field commands if required * * submit_mult_*_x comes from IE if is used */ if (isset($_REQUEST['submit_mult_change_x'])) { $submit_mult = 'change'; } elseif (isset($_REQUEST['submit_mult_drop_x'])) { $submit_mult = 'drop'; } elseif (isset($_REQUEST['submit_mult_primary_x'])) { $submit_mult = 'primary'; } elseif (isset($_REQUEST['submit_mult_index_x'])) { $submit_mult = 'index'; } elseif (isset($_REQUEST['submit_mult_unique_x'])) { $submit_mult = 'unique'; } elseif (isset($_REQUEST['submit_mult_spatial_x'])) { $submit_mult = 'spatial'; } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) { $submit_mult = 'ftext'; } elseif (isset($_REQUEST['submit_mult_browse_x'])) { $submit_mult = 'browse'; } elseif (isset($_REQUEST['submit_mult'])) { $submit_mult = $_REQUEST['submit_mult']; } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) { $submit_mult = 'row_delete'; if (isset($_REQUEST['selected'])) { $_REQUEST['selected_fld'] = $_REQUEST['selected']; } } if (! empty($submit_mult)) { if (isset($_REQUEST['selected_fld'])) { $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); if ($submit_mult == 'browse') { // browsing the table displaying only selected columns $GLOBALS['active_page'] = 'sql.php'; $sql_query = ''; foreach ($_REQUEST['selected_fld'] as $idx => $sval) { if ($sql_query == '') { $sql_query .= 'SELECT ' . PMA_Util::backquote($sval); } else { $sql_query .= ', ' . PMA_Util::backquote($sval); } } $sql_query .= ' FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table); // Parse and analyze the query require_once 'libraries/parse_analyze.inc.php'; PMA_executeQueryAndSendQueryResponse( $analyzed_sql_results, false, $db, $table, null, null, null, false, null, null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, null, null ); } else { // handle multiple field commands // handle confirmation of deleting multiple columns $action = 'tbl_structure.php'; include 'libraries/mult_submits.inc.php'; /** * if $submit_mult == 'change', execution will have stopped * at this point */ if (empty($message)) { $message = PMA_Message::success(); } } } else { $response = PMA_Response::getInstance(); $response->isSuccess(false); $response->addJSON('message', __('No column selected.')); } } /** * Gets the relation settings */ $cfgRelation = PMA_getRelationsParam(); /** * Runs common work */ require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php'; $url_params['goto'] = 'tbl_structure.php'; $url_params['back'] = 'tbl_structure.php'; // Check column names for MySQL reserved words $reserved_word_column_messages = PMA_getReservedWordColumnNameMessages($db, $table); $response->addHTML($reserved_word_column_messages); /** * Prepares the table structure display */ /** * Gets tables informations */ require_once 'libraries/tbl_info.inc.php'; require_once 'libraries/Index.class.php'; // 2. Gets table keys and retains them // @todo should be: $server->db($db)->table($table)->primary() $primary = PMA_Index::getPrimary($table, $db); $columns_with_unique_index = PMA_getColumnsWithUniqueIndex($db, $table); // 3. Get fields $fields = (array) $GLOBALS['dbi']->getColumns($db, $table, null, true); // Get more complete field information // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options // but later, if the analyser returns more information, it // could be executed for any MySQL version and replace // the info given by SHOW FULL COLUMNS FROM. // // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since // SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL // and SHOW CREATE TABLE says NOT NULL (tested // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). $show_create_table = $GLOBALS['dbi']->fetchValue( 'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table), 0, 1 ); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); /** * prepare table infos */ // action titles (image or string) $titles = PMA_getActionTitlesArray(); // hidden action titles (image and string) $hidden_titles = PMA_getHiddenTitlesArray(); //display table structure require_once 'libraries/display_structure.lib.php'; ?>