/** * Function to get html to display problems in indexes * * @param string $query_type query type * @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 $db current database * * @return string */ function PMA_getHtmlForIndexesProblems($query_type, $selectedTables, $db) { // BEGIN INDEX CHECK See if indexes should be checked. if (isset($query_type) && $query_type == 'check_tbl' && isset($selectedTables) && is_array($selectedTables)) { $indexes_problems_html = ''; foreach ($selectedTables as $tbl_name) { $check = PMA_Index::findDuplicates($tbl_name, $db); if (!empty($check)) { $indexes_problems_html .= sprintf(__('Problems with indexes of table `%s`'), $tbl_name); $indexes_problems_html .= $check; } } } else { $indexes_problems_html = null; } return $indexes_problems_html; }
$disp_mode = 'nnnn110111'; } if (isset($label)) { $message = PMA_message::success(__('Bookmark %s created')); $message->addParam($label); $message->display(); } PMA_displayTable($result, $disp_mode, $analyzed_sql); PMA_DBI_free_result($result); // BEGIN INDEX CHECK See if indexes should be checked. if (isset($query_type) && $query_type == 'check_tbl' && isset($selected) && is_array($selected)) { foreach ($selected as $idx => $tbl_name) { $check = PMA_Index::findDuplicates($tbl_name, $db); if (! empty($check)) { printf(__('Problems with indexes of table `%s`'), $tbl_name); echo $check; } } } // End INDEX CHECK // Bookmark support if required if ($disp_mode[7] == '1' && (! empty($cfg['Bookmark']) && empty($id_bookmark)) && ! empty($sql_query) ) { echo "\n"; $goto = 'sql.php?'
/** * Show index data * * @param string $table The table name * @param string $schema The schema name * @param boolean $print_mode Whether the output is for the print mode * * @return string HTML for showing index * * @access public */ public static function getView($table, $schema, $print_mode = false) { $indexes = PMA_Index::getFromTable($table, $schema); $no_indexes_class = count($indexes) > 0 ? ' hide' : ''; $no_indexes = "<div class='no_indexes_defined{$no_indexes_class}'>"; $no_indexes .= PMA_Message::notice(__('No index defined!'))->getDisplay(); $no_indexes .= '</div>'; if (!$print_mode) { $r = '<fieldset class="index_info">'; $r .= '<legend id="index_header">' . __('Indexes'); $r .= PMA_Util::showMySQLDocu('optimizing-database-structure'); $r .= '</legend>'; $r .= $no_indexes; if (count($indexes) < 1) { $r .= '</fieldset>'; return $r; } $r .= PMA_Index::findDuplicates($table, $schema); } else { $r = '<h3>' . __('Indexes') . '</h3>'; $r .= $no_indexes; if (count($indexes) < 1) { return $r; } } $r .= '<table id="table_index">'; $r .= '<thead>'; $r .= '<tr>'; if (!$print_mode) { $r .= '<th colspan="2">' . __('Action') . '</th>'; } $r .= '<th>' . __('Keyname') . '</th>'; $r .= '<th>' . __('Type') . '</th>'; $r .= '<th>' . __('Unique') . '</th>'; $r .= '<th>' . __('Packed') . '</th>'; $r .= '<th>' . __('Column') . '</th>'; $r .= '<th>' . __('Cardinality') . '</th>'; $r .= '<th>' . __('Collation') . '</th>'; $r .= '<th>' . __('Null') . '</th>'; if (PMA_MYSQL_INT_VERSION > 50500) { $r .= '<th>' . __('Comment') . '</th>'; } $r .= '</tr>'; $r .= '</thead>'; $r .= '<tbody>'; $odd_row = true; foreach ($indexes as $index) { $row_span = ' rowspan="' . $index->getColumnCount() . '" '; $r .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'; if (!$print_mode) { $this_params = $GLOBALS['url_params']; $this_params['index'] = $index->getName(); $r .= '<td class="edit_index'; $r .= ' ajax'; $r .= '" ' . $row_span . '>' . ' <a class="'; $r .= 'ajax'; $r .= '" href="tbl_indexes.php' . PMA_URL_getCommon($this_params) . '">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>' . '</td>' . "\n"; $this_params = $GLOBALS['url_params']; if ($index->getName() == 'PRIMARY') { $this_params['sql_query'] = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' DROP PRIMARY KEY;'; $this_params['message_to_show'] = __('The primary key has been dropped.'); $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY'); } else { $this_params['sql_query'] = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' DROP INDEX ' . PMA_Util::backquote($index->getName()) . ';'; $this_params['message_to_show'] = sprintf(__('Index %s has been dropped.'), $index->getName()); $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName() . ';'); } $r .= '<td ' . $row_span . '>'; $r .= '<input type="hidden" class="drop_primary_key_index_msg"' . ' value="' . $js_msg . '" />'; $r .= ' <a class="drop_primary_key_index_anchor'; $r .= ' ajax'; $r .= '" href="sql.php' . PMA_URL_getCommon($this_params) . '" >' . PMA_Util::getIcon('b_drop.png', __('Drop')) . '</a>' . '</td>' . "\n"; } if (!$print_mode) { $r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>'; } else { $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</td>'; } $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getType()) . '</td>'; $r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>'; $r .= '<td ' . $row_span . '>' . $index->isPacked(true) . '</td>'; foreach ($index->getColumns() as $column) { if ($column->getSeqInIndex() > 1) { $r .= '<tr class="noclick ' . ($odd_row ? 'odd' : 'even') . '">'; } $r .= '<td>' . htmlspecialchars($column->getName()); if ($column->getSubPart()) { $r .= ' (' . $column->getSubPart() . ')'; } $r .= '</td>'; $r .= '<td>' . htmlspecialchars($column->getCardinality()) . '</td>'; $r .= '<td>' . htmlspecialchars($column->getCollation()) . '</td>'; $r .= '<td>' . htmlspecialchars($column->getNull(true)) . '</td>'; if (PMA_MYSQL_INT_VERSION > 50500 && $column->getSeqInIndex() == 1) { $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getComments()) . '</td>'; } $r .= '</tr>'; } // end foreach $index['Sequences'] $odd_row = !$odd_row; } // end while $r .= '</tbody>'; $r .= '</table>'; if (!$print_mode) { $r .= '</fieldset>'; } return $r; }
/** * Show index data * * @param string $table The tablename * @param array $indexes_info Referenced info array * @param array $indexes_data Referenced data array * @param boolean $print_mode * @access public * @return array Index collection array */ public static function getView($table, $schema, $print_mode = false) { $indexes = PMA_Index::getFromTable($table, $schema); if (count($indexes) < 1) { return PMA_Message::error(__('No index defined!'))->getDisplay(); } $r = ''; $r .= '<h2>' . __('Indexes') . ': '; $r .= PMA_showMySQLDocu('optimization', 'optimizing-database-structure'); $r .= '</h2>'; $r .= '<table>'; $r .= '<thead>'; $r .= '<tr>'; if (!$print_mode) { $r .= '<th colspan="2">' . __('Action') . '</th>'; } $r .= '<th>' . __('Keyname') . '</th>'; $r .= '<th>' . __('Type') . '</th>'; $r .= '<th>' . __('Unique') . '</th>'; $r .= '<th>' . __('Packed') . '</th>'; $r .= '<th>' . __('Column') . '</th>'; $r .= '<th>' . __('Cardinality') . '</th>'; $r .= '<th>' . __('Collation') . '</th>'; $r .= '<th>' . __('Null') . '</th>'; $r .= '<th>' . __('Comment') . '</th>'; $r .= '</tr>'; $r .= '</thead>'; $r .= '<tbody>'; $odd_row = true; foreach ($indexes as $index) { $row_span = ' rowspan="' . $index->getColumnCount() . '" '; $r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">'; if (!$print_mode) { $this_params = $GLOBALS['url_params']; $this_params['index'] = $index->getName(); $r .= '<td ' . $row_span . '>' . ' <a href="tbl_indexes.php' . PMA_generate_common_url($this_params) . '">' . PMA_getIcon('b_edit.png', __('Edit')) . '</a>' . '</td>' . "\n"; $this_params = $GLOBALS['url_params']; if ($index->getName() == 'PRIMARY') { $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY'; $this_params['message_to_show'] = __('The primary key has been dropped'); $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY'); } else { $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index->getName()); $this_params['message_to_show'] = sprintf(__('Index %s has been dropped'), $index->getName()); $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName()); } $r .= '<td ' . $row_span . '>'; $r .= '<input type="hidden" class="drop_primary_key_index_msg" value="' . $js_msg . '" />'; $r .= ' <a '; if ($GLOBALS['cfg']['AjaxEnable']) { $r .= 'class="drop_primary_key_index_anchor" '; } $r .= ' href="sql.php' . PMA_generate_common_url($this_params) . '" >' . PMA_getIcon('b_drop.png', __('Drop')) . '</a>' . '</td>' . "\n"; } $r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>'; $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getType()) . '</td>'; $r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>'; $r .= '<td ' . $row_span . '>' . $index->isPacked(true) . '</td>'; foreach ($index->getColumns() as $column) { if ($column->getSeqInIndex() > 1) { $r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">'; } $r .= '<td>' . htmlspecialchars($column->getName()); if ($column->getSubPart()) { $r .= ' (' . $column->getSubPart() . ')'; } $r .= '</td>'; $r .= '<td>' . htmlspecialchars($column->getCardinality()) . '</td>'; $r .= '<td>' . htmlspecialchars($column->getCollation()) . '</td>'; $r .= '<td>' . htmlspecialchars($column->getNull()) . '</td>'; if ($column->getSeqInIndex() == 1) { $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getComments()) . '</td>'; } $r .= '</tr>'; } // end foreach $index['Sequences'] $odd_row = !$odd_row; } // end while $r .= '</tbody>'; $r .= '</table>'; if (!$print_mode) { $r .= PMA_Index::findDuplicates($table, $schema); } return $r; }
/** * Show index data * * @param string $table The tablename * @param array $indexes_info Referenced info array * @param array $indexes_data Referenced data array * @param boolean $print_mode * @access public * @return array Index collection array * @author Garvin Hicking (pma@supergarv.de) */ static public function getView($table, $schema, $print_mode = false) { $indexes = PMA_Index::getFromTable($table, $schema); if (count($indexes) < 1) { return PMA_Message::warning('strNoIndex')->getDisplay(); } $r = ''; $r .= '<h2>' . $GLOBALS['strIndexes'] . ': '; $r .= PMA_showMySQLDocu('optimization', 'optimizing-database-structure'); $r .= '</h2>'; $r .= '<table>'; $r .= '<thead>'; $r .= '<tr>'; if (! $print_mode) { $r .= '<th colspan="2">' . $GLOBALS['strAction'] . '</th>'; } $r .= '<th>' . $GLOBALS['strKeyname'] . '</th>'; $r .= '<th>' . $GLOBALS['strType'] . '</th>'; $r .= '<th>' . $GLOBALS['strUnique'] . '</th>'; $r .= '<th>' . $GLOBALS['strPacked'] . '</th>'; $r .= '<th>' . $GLOBALS['strField'] . '</th>'; $r .= '<th>' . $GLOBALS['strCardinality'] . '</th>'; $r .= '<th>' . $GLOBALS['strCollation'] . '</th>'; $r .= '<th>' . $GLOBALS['strNull'] . '</th>'; $r .= '<th>' . $GLOBALS['strComment'] . '</th>'; $r .= '</tr>'; $r .= '</thead>'; $r .= '<tbody>'; $odd_row = true; foreach ($indexes as $index) { $row_span = ' rowspan="' . $index->getColumnCount() . '" '; $r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">'; if (! $print_mode) { $this_params = $GLOBALS['url_params']; $this_params['index'] = $index->getName(); $r .= '<td ' . $row_span . '>' . ' <a href="tbl_indexes.php' . PMA_generate_common_url($this_params) . '">' . PMA_getIcon('b_edit.png', $GLOBALS['strEdit']) . '</a>' . '</td>' . "\n"; $this_params = $GLOBALS['url_params']; if ($index->getName() == 'PRIMARY') { $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY'; $this_params['zero_rows'] = $GLOBALS['strPrimaryKeyHasBeenDropped']; $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY'); } else { $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index->getName()); $this_params['zero_rows'] = sprintf($GLOBALS['strIndexHasBeenDropped'], $index->getName()); $js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName()); } $r .= '<td ' . $row_span . '>' . ' <a href="sql.php' . PMA_generate_common_url($this_params) . '" onclick="return confirmLink(this, \'' . $js_msg . '\')">' . PMA_getIcon('b_drop.png', $GLOBALS['strDrop']) . '</a>' . '</td>' . "\n"; } $r .= '<th ' . $row_span . '>' . htmlspecialchars($index->getName()) . '</th>'; $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getType()) . '</td>'; $r .= '<td ' . $row_span . '>' . $index->isUnique(true) . '</td>'; $r .= '<td ' . $row_span . '>' . $index->isPacked(true) . '</td>'; foreach ($index->getColumns() as $column) { if ($column->getSeqInIndex() > 1) { $r .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">'; } $r .= '<td>' . htmlspecialchars($column->getName()); if ($column->getSubPart()) { $r .= ' (' . $column->getSubPart() . ')'; } $r .= '</td>'; $r .= '<td>' . htmlspecialchars($column->getCardinality()) . '</td>'; $r .= '<td>' . htmlspecialchars($column->getCollation()) . '</td>'; $r .= '<td>' . htmlspecialchars($column->getNull()) . '</td>'; if ($column->getSeqInIndex() == 1) { $r .= '<td ' . $row_span . '>' . htmlspecialchars($index->getComments()) . '</td>'; } $r .= '</tr>'; } // end foreach $index['Sequences'] $odd_row = ! $odd_row; } // end while $r .= '</tbody>'; $r .= '</table>'; if (! $print_mode) { $r .= PMA_Index::findDuplicates($table, $schema); } return $r; }