/** * Returns the html for Collations of Current Charset. * * @param String $currCharset Current Charset * @param Array $mysqlColl Collations list * @param Array $mysqlDefaultColl Default Collations list * @param Array $mysqlCollAvailable Available Collations list * * @return string */ function PMA_getHtmlForCollationCurrentCharset($currCharset, $mysqlColl, $mysqlDefaultColl, $mysqlCollAvailable) { $odd_row = true; $html = ''; foreach ($mysqlColl[$currCharset] as $current_collation) { $html .= '<tr class="' . ($odd_row ? 'odd' : 'even') . ($mysqlDefaultColl[$currCharset] == $current_collation ? ' marked' : '') . ($mysqlCollAvailable[$current_collation] ? '' : ' disabled') . '">' . "\n" . ' <td>' . htmlspecialchars($current_collation) . '</td>' . "\n" . ' <td>' . PMA_getCollationDescr($current_collation) . '</td>' . "\n" . '</tr>' . "\n"; $odd_row = !$odd_row; } return $html; }
function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = null, $id = null, $default = null, $label = TRUE, $indent = 0, $submitOnChange = FALSE, $displayUnavailable = FALSE) { global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available; if (empty($name)) { if ($type == PMA_CSDROPDOWN_COLLATION) { $name = 'collation'; } else { $name = 'character_set'; } } $spacer = ''; for ($i = 1; $i <= $indent; $i++) { $spacer .= ' '; } $return_str = $spacer . '<select xml:lang="en" dir="ltr" name="' . htmlspecialchars($name) . '"' . (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"') . ($submitOnChange ? ' onchange="this.form.submit();"' : '') . '>' . "\n"; if ($label) { $return_str .= $spacer . ' <option value="">' . ($type == PMA_CSDROPDOWN_COLLATION ? $GLOBALS['strCollation'] : $GLOBALS['strCharset']) . '</option>' . "\n"; } $return_str .= $spacer . ' <option value=""> </option>' . "\n"; foreach ($mysql_charsets as $current_charset) { if (!$mysql_charsets_available[$current_charset]) { continue; } $current_cs_descr = empty($mysql_charsets_descriptions[$current_charset]) ? $current_charset : $mysql_charsets_descriptions[$current_charset]; if ($type == PMA_CSDROPDOWN_COLLATION) { $return_str .= $spacer . ' <optgroup label="' . $current_charset . '" title="' . $current_cs_descr . '">' . "\n"; foreach ($mysql_collations[$current_charset] as $current_collation) { if (!$mysql_collations_available[$current_collation]) { continue; } $return_str .= $spacer . ' <option value="' . $current_collation . '" title="' . PMA_getCollationDescr($current_collation) . '"' . ($default == $current_collation ? ' selected="selected"' : '') . '>' . $current_collation . '</option>' . "\n"; } $return_str .= $spacer . ' </optgroup>' . "\n"; } else { $return_str .= $spacer . ' <option value="' . $current_charset . '" title="' . $current_cs_descr . '"' . ($default == $current_charset ? ' selected="selected"' : '') . '>' . $current_charset . '</option>' . "\n"; } } $return_str .= $spacer . '</select>' . "\n"; return $return_str; }
/** * Generate charset dropdown box * * @param int $type Type * @param string $name Element name * @param string $id Element id * @param null|string $default Default value * @param bool $label Label * @param bool $submitOnChange Submit on change * * @return string */ function PMA_generateCharsetDropdownBox($type = PMA_CSDROPDOWN_COLLATION, $name = null, $id = null, $default = null, $label = true, $submitOnChange = false) { global $mysql_charsets, $mysql_charsets_descriptions, $mysql_charsets_available, $mysql_collations, $mysql_collations_available; if (empty($name)) { if ($type == PMA_CSDROPDOWN_COLLATION) { $name = 'collation'; } else { $name = 'character_set'; } } $return_str = '<select lang="en" dir="ltr" name="' . htmlspecialchars($name) . '"' . (empty($id) ? '' : ' id="' . htmlspecialchars($id) . '"') . ($submitOnChange ? ' class="autosubmit"' : '') . '>' . "\n"; if ($label) { $return_str .= '<option value="">' . ($type == PMA_CSDROPDOWN_COLLATION ? __('Collation') : __('Charset')) . '</option>' . "\n"; } $return_str .= '<option value=""></option>' . "\n"; foreach ($mysql_charsets as $current_charset) { if (!$mysql_charsets_available[$current_charset]) { continue; } $current_cs_descr = empty($mysql_charsets_descriptions[$current_charset]) ? $current_charset : $mysql_charsets_descriptions[$current_charset]; if ($type == PMA_CSDROPDOWN_COLLATION) { $return_str .= '<optgroup label="' . $current_charset . '" title="' . $current_cs_descr . '">' . "\n"; foreach ($mysql_collations[$current_charset] as $current_collation) { if (!$mysql_collations_available[$current_collation]) { continue; } $return_str .= '<option value="' . $current_collation . '" title="' . PMA_getCollationDescr($current_collation) . '"' . ($default == $current_collation ? ' selected="selected"' : '') . '>' . $current_collation . '</option>' . "\n"; } $return_str .= '</optgroup>' . "\n"; } else { $return_str .= '<option value="' . $current_charset . '" title="' . $current_cs_descr . '"' . ($default == $current_charset ? ' selected="selected"' : '') . '>' . $current_charset . '</option>' . "\n"; } } $return_str .= '</select>' . "\n"; return $return_str; }
/** * Get HTML snippet for display Row statistics table * * @param array $showtable show table array * @param string $tbl_collation table collation * @param boolean $is_innodb whether table is innob or not * @param boolean $mergetable Checks if current table is a merge table * @param integer $avg_size average size * @param string $avg_unit average unit * * @return string $html_output */ function getHtmlForRowStatsTable($showtable, $tbl_collation, $is_innodb, $mergetable, $avg_size, $avg_unit) { $odd_row = false; $html_output = '<table id="tablerowstats" class="data">'; $html_output .= '<caption class="tblHeaders">' . __('Row statistics') . '</caption>'; $html_output .= '<tbody>'; if (isset($showtable['Row_format'])) { if ($showtable['Row_format'] == 'Fixed') { $value = __('static'); } elseif ($showtable['Row_format'] == 'Dynamic') { $value = __('dynamic'); } else { $value = $showtable['Row_format']; } $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Format'), $value); $odd_row = !$odd_row; } if (!empty($showtable['Create_options'])) { if ($showtable['Create_options'] == 'partitioned') { $value = __('partitioned'); } else { $value = $showtable['Create_options']; } $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Options'), $value); $odd_row = !$odd_row; } if (!empty($tbl_collation)) { $value = '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>'; $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Collation'), $value); $odd_row = !$odd_row; } if (!$is_innodb && isset($showtable['Rows'])) { $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Rows'), PMA_Util::formatNumber($showtable['Rows'], 0)); $odd_row = !$odd_row; } if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) { list($avg_row_length_value, $avg_row_length_unit) = PMA_Util::formatByteDown($showtable['Avg_row_length'], 6, 1); $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Row length'), $avg_row_length_value . ' ' . $avg_row_length_unit); unset($avg_row_length_value, $avg_row_length_unit); $odd_row = !$odd_row; } if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) { $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Row size'), $avg_size . ' ' . $avg_unit); $odd_row = !$odd_row; } if (isset($showtable['Auto_increment'])) { $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Next autoindex'), PMA_Util::formatNumber($showtable['Auto_increment'], 0)); $odd_row = !$odd_row; } if (isset($showtable['Create_time'])) { $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Creation'), PMA_Util::localisedDate(strtotime($showtable['Create_time']))); $odd_row = !$odd_row; } if (isset($showtable['Update_time'])) { $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Last update'), PMA_Util::localisedDate(strtotime($showtable['Update_time']))); $odd_row = !$odd_row; } if (isset($showtable['Check_time'])) { $html_output .= PMA_getHtmlForRowStatsTableRow($odd_row, __('Last check'), PMA_Util::localisedDate(strtotime($showtable['Check_time']))); } $html_output .= '</tbody>' . '</table>'; return $html_output; }
unset($truename); } $new_table_string .= '</th>' . "\n"; $new_table_string .= '<td>' . $titles['NoBrowse'] . '</td>' . "\n"; $new_table_string .= '<td><a href="tbl_structure.php' . PMA_generate_common_url($tbl_url_params) . '">' . $titles['Structure'] . '</a></td>' . "\n"; $new_table_string .= '<td>' . $titles['NoSearch'] . '</td>' . "\n"; $new_table_string .= '<td><a href="tbl_change.php' . PMA_generate_common_url($tbl_url_params) . '">' . $titles['Insert'] . '</a></td>' . "\n"; $new_table_string .= '<td>' . $titles['NoEmpty'] . '</td>' . "\n"; $new_table_string .= '<td><a class="drop_table_anchor" href="sql.php' . PMA_generate_common_url($tbl_url_params) . '&sql_query='; $new_table_string .= urlencode('DROP TABLE ' . PMA_backquote($table)); $new_table_string .= '">'; $new_table_string .= $titles['Drop']; $new_table_string .= '</a></td>' . "\n"; $new_table_string .= '<td class="value">' . $tbl_stats['Rows'] . '</td>' . "\n"; $new_table_string .= '<td nowrap="nowrap">' . $tbl_stats['Engine'] . '</td>' . "\n"; $new_table_string .= '<td> <dfn title="' . PMA_getCollationDescr($tbl_stats['Collation']) . '">' . $tbl_stats['Collation'] . '</dfn></td>' . "\n"; if ($is_show_stats) { $new_table_string .= '<td class="value"> <a href="tbl_structure.php' . PMA_generate_common_url($tbl_url_params) . '#showusage" >' . $formatted_size . ' ' . $unit . '</a> </td>' . "\n"; $new_table_string .= '<td class="value">' . $overhead . '</td>' . "\n"; } $new_table_string .= '</tr>' . "\n"; $extra_data['new_table_string'] = $new_table_string; PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); } $display_query = $sql_query; $sql_query = ''; // read table info on this newly created table, in case // the next page is Structure $reread_info = true; require './libraries/tbl_info.inc.php'; // do not switch to sql.php - as there is no row to be displayed on a new table
*/ if (PMA_MYSQL_INT_VERSION < 40100) { require_once './libs/footer.inc.php'; } /** * Includes the required charset library */ require_once './libs/mysql_charsets.lib.php'; /** * Outputs the result */ echo '<div id="div_mysql_charset_collations">' . "\n" . '<table class="data">' . "\n" . '<tr><th>' . $strCollation . '</th>' . "\n" . ' <th>' . $strDescription . '</th>' . "\n" . '</tr>' . "\n"; $i = 0; $table_row_count = count($mysql_charsets) + $mysql_collations_count; foreach ($mysql_charsets as $current_charset) { if ($i >= $table_row_count / 2) { $i = 0; echo '</table>' . "\n" . '<table class="data">' . "\n" . '<tr><th>' . $strCollation . '</th>' . "\n" . ' <th>' . $strDescription . '</th>' . "\n" . '</tr>' . "\n"; } $i++; echo '<tr><th colspan="2" align="right">' . "\n" . ' ' . htmlspecialchars($current_charset) . "\n" . (empty($mysql_charsets_descriptions[$current_charset]) ? '' : ' (<i>' . htmlspecialchars($mysql_charsets_descriptions[$current_charset]) . '</i>)' . "\n") . ' </th>' . "\n" . '</tr>' . "\n"; $odd_row = true; foreach ($mysql_collations[$current_charset] as $current_collation) { $i++; echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ($mysql_default_collations[$current_charset] == $current_collation ? ' marked' : '') . ($mysql_collations_available[$current_collation] ? '' : ' disabled') . '">' . "\n" . ' <td>' . htmlspecialchars($current_collation) . '</td>' . "\n" . ' <td>' . PMA_getCollationDescr($current_collation) . '</td>' . "\n" . '</tr>' . "\n"; $odd_row = !$odd_row; } } unset($table_row_count); echo '</table>' . "\n" . '</div>' . "\n"; require_once './libs/footer.inc.php';
. PMA_generate_common_url($tbl_url_params) . '&sql_query=' . urlencode('DROP TABLE ' . PMA_Util::backquote($table)) . '">' . $titles['Drop'] . '</a>' . '</td>' . "\n"; $new_table_string .= '<td class="value">' . $tbl_stats['Rows'] . '</td>' . "\n"; $new_table_string .= '<td class="nowrap">' . $tbl_stats['Engine'] . '</td>' . "\n"; $new_table_string .= '<td>' . '<dfn title="' . PMA_getCollationDescr($tbl_stats['Collation']) . '">' . $tbl_stats['Collation'] .'</dfn>' . '</td>' . "\n"; if ($is_show_stats) { $new_table_string .= '<td class="value tbl_size">' . '<a href="tbl_structure.php' . PMA_generate_common_url($tbl_url_params) . '#showusage" >' . '<span>' . $formatted_size . '</span>' . '<span class="unit">' . $unit . '</span>' . '</a>' . '</td>' . "\n" ; $new_table_string .= '<td class="value tbl_overhead">' . $overhead
<?php echo __('Sum'); ?> </th> <th class="value tbl_rows"><?php echo $sum_row_count_pre . PMA_formatNumber($sum_entries, 0); ?> </th> <?php if (!($cfg['PropertiesNumColumns'] > 1)) { $default_engine = PMA_DBI_get_default_engine(); echo ' <th align="center">' . "\n" . ' <dfn title="' . sprintf(__('%s is the default storage engine on this MySQL server.'), $default_engine) . '">' . $default_engine . '</dfn></th>' . "\n"; // we got a case where $db_collation was empty echo ' <th align="center">' . "\n"; if (!empty($db_collation)) { echo ' <dfn title="' . PMA_getCollationDescr($db_collation) . ' (' . __('Default') . ')">' . $db_collation . '</dfn>'; } echo '</th>'; } if ($is_show_stats) { ?> <th class="value tbl_size"><?php echo $sum_formatted . ' ' . $unit; ?> </th> <th class="value"><?php echo $overhead_formatted . ' ' . $overhead_unit; ?> </th> <?php }
foreach ($tables as $keyname => $current_table) { // Get valid statistics whatever is the table type $drop_query = ''; $drop_message = ''; $overhead = ''; $table_is_view = false; $table_encoded = urlencode($current_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $url_query . '&table=' . $table_encoded; // do not list the previous table's size info for a view list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = PMA_getStuffForEngineTypeTable($current_table, $db_is_information_schema, $is_show_stats, $table_is_view, $sum_size, $overhead_size); if (!PMA_Table::isMerge($db, $current_table['TABLE_NAME'])) { $sum_entries += $current_table['TABLE_ROWS']; } if (isset($current_table['Collation'])) { $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>'; } else { $collation = '---'; } if ($is_show_stats) { if ($formatted_overhead != '') { $overhead = '<a href="tbl_structure.php?' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span>' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n"; $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');"; } else { $overhead = '-'; } } // end if unset($showtable); if ($GLOBALS['cfg']['ShowDbStructureCreation']) { list($create_time, $create_time_all) = PMA_getTimeForCreateUpdateCheck($current_table, 'Create_time', $create_time_all);
/** * Test case for PMA_getCollationDescr() * * @param string $collation Collation for which description is reqd * @param string $desc Expected Description * * @return void * @test * @dataProvider collationDescr */ public function testGetCollationDescr($collation, $desc) { $this->assertEquals($desc, PMA_getCollationDescr($collation)); }
if (PMA_MYSQL_INT_VERSION < 40100) { // TODO: Some nice Message :-) require_once './footer.inc.php'; } /** * Includes the required charset library */ require_once './libraries/mysql_charsets.lib.php'; /** * Outputs the result */ echo '<table border="0">' . "\n" . ' <tr>' . "\n" . ' <td valign="top">' . "\n" . ' <table border="0" cellpadding="2" cellspacing="1">' . "\n" . ' <tr>' . "\n" . ' <th>' . "\n" . ' ' . $strCollation . "\n" . ' </th>' . "\n" . ' <th>' . "\n" . ' ' . $strDescription . "\n" . ' </th>' . "\n" . ' </tr>' . "\n"; $i = 0; $table_row_count = count($mysql_charsets) + $mysql_collations_count; foreach ($mysql_charsets as $current_charset) { if ($i >= $table_row_count / 2) { $i = 0; echo ' </table>' . "\n" . ' </td>' . "\n" . ' <td valign="top">' . "\n" . ' <table border="0" cellpadding="2" cellspacing="1">' . "\n" . ' <tr>' . "\n" . ' <th>' . "\n" . ' ' . $strCollation . "\n" . ' </th>' . "\n" . ' <th>' . "\n" . ' ' . $strDescription . "\n" . ' </th>' . "\n" . ' </tr>' . "\n"; } $i++; echo ' <tr>' . "\n" . ' <td colspan="2" bgcolor="' . $cfg['ThBgcolor'] . '" align="right">' . "\n" . ' <b>' . htmlspecialchars($current_charset) . '</b>' . "\n" . (empty($mysql_charsets_descriptions[$current_charset]) ? '' : ' (<i>' . htmlspecialchars($mysql_charsets_descriptions[$current_charset]) . '</i>) ' . "\n") . ' </td>' . "\n" . ' </tr>' . "\n"; $useBgcolorOne = TRUE; foreach ($mysql_collations[$current_charset] as $current_collation) { $i++; echo ' <tr>' . "\n" . ' <td bgcolor="' . ($mysql_default_collations[$current_charset] == $current_collation ? $cfg['BrowseMarkerColor'] : ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'])) . '">' . "\n" . ' ' . htmlspecialchars($current_collation) . ' ' . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' ' . PMA_getCollationDescr($current_collation) . ' ' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n"; $useBgcolorOne = !$useBgcolorOne; } } unset($table_row_count); echo ' </table>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . '</table>' . "\n"; require_once './footer.inc.php';
<b><?php echo $strSum; ?> </b> </th> <th align="right" nowrap="nowrap"> <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?> </b> </th> <?php if (!($cfg['PropertiesNumColumns'] > 1)) { echo ' <th align="center">' . "\n" . ' <b>--</b>' . "\n" . ' </th>' . "\n"; if (PMA_MYSQL_INT_VERSION >= 40101) { echo ' <th align="center">' . "\n" . ' <b><dfn title="' . PMA_getCollationDescr($db_collation) . '">' . $db_collation . '</dfn></b> ' . "\n" . ' </th>' . "\n"; } } if ($cfg['ShowStats']) { echo "\n"; ?> <th align="right" nowrap="nowrap"> <b><?php echo $sum_formated . ' ' . $unit; ?> </b> </th> <th align="right" nowrap="nowrap"> <b><?php
?> </th> <th colspan="<?php echo ($db_is_information_schema ? 3 : 6) ?>" align="center"> <?php echo $strSum; ?></th> <th class="value"><?php echo $sum_row_count_pre . PMA_formatNumber($sum_entries, 0); ?></th> <?php if (!($cfg['PropertiesNumColumns'] > 1)) { $default_engine = PMA_DBI_get_default_engine(); echo ' <th align="center">' . "\n" . ' <dfn title="' . sprintf($strDefaultEngine, $default_engine) . '">' .$default_engine . '</dfn></th>' . "\n"; // we got a case where $db_collation was empty echo ' <th align="center">' . "\n"; if (! empty($db_collation)) { echo ' <dfn title="' . PMA_getCollationDescr($db_collation) . ' (' . $strDefault . ')">' . $db_collation . '</dfn>'; } echo '</th>'; } if ($is_show_stats) { ?> <th class="value"><?php echo $sum_formatted . ' ' . $unit; ?></th> <th class="value"><?php echo $overhead_formatted . ' ' . $overhead_unit; ?></th> <?php } ?> </tr> </tbody> </table>
. (empty($mysql_charsets_descriptions[$current_charset]) ? '' : ' (<i>' . htmlspecialchars( $mysql_charsets_descriptions[$current_charset] ) . '</i>)' . "\n") . ' </th>' . "\n" . '</tr>' . "\n"; $odd_row = true; foreach ($mysql_collations[$current_charset] as $current_collation) { $i++; echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ($mysql_default_collations[$current_charset] == $current_collation ? ' marked' : '') . ($mysql_collations_available[$current_collation] ? '' : ' disabled') . '">' . "\n" . ' <td>' . htmlspecialchars($current_collation) . '</td>' . "\n" . ' <td>' . PMA_getCollationDescr($current_collation) . '</td>' . "\n" . '</tr>' . "\n"; $odd_row = !$odd_row; } } unset($table_row_count); echo '</table>' . "\n" . '</div>' . "\n"; require 'libraries/footer.inc.php'; ?>
</td> </tr> <?php } if (!empty($tbl_collation)) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> "> <th class="name"><?php echo $strCollation; ?> </th> <td class="value"><?php echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>'; ?> </td> </tr> <?php } if (!$is_innodb && isset($showtable['Rows'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> "> <th class="name"><?php echo $strRows; ?> </th>
list($idx_size, $idx_unit) = PMA_formatByteDown($current['idx_sz'], 3, 1); list($tot_size, $tot_unit) = PMA_formatByteDown($current['tot_sz'], 3, 1); $total_calc['db_cnt']++; $total_calc['tbl_cnt'] += $current['tbl_cnt']; $total_calc['data_sz'] += $current['data_sz']; $total_calc['idx_sz'] += $current['idx_sz']; $total_calc['tot_sz'] += $current['tot_sz']; echo ' <tr>' . "\n"; if ($is_superuser || $cfg['AllowUserDropDatabase']) { echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' <input type="checkbox" name="selected_db[]" title="' . htmlspecialchars($current['db_name']) . '" value="' . htmlspecialchars($current['db_name']) . '" ' . (empty($checkall) ? '' : 'checked="checked" ') . '/>' . "\n" . ' </td>' . "\n"; } echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' <a onclick="reload_window(\'' . urlencode($current['db_name']) . '\'); return true;" href="' . $cfg['DefaultTabDatabase'] . '?' . $url_query . '&db=' . urlencode($current['db_name']) . '" title="' . sprintf($strJumpToDB, htmlspecialchars($current['db_name'])) . '">' . "\n" . ' ' . htmlspecialchars($current['db_name']) . "\n" . ' </a>' . "\n" . ' </td>' . "\n"; if (!empty($dbstats)) { if (PMA_MYSQL_INT_VERSION >= 40101) { $current_collation = PMA_getDbCollation($current['db_name']); echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' <dfn title="' . htmlspecialchars(PMA_getCollationDescr($current_collation)) . '">' . "\n" . ' ' . htmlspecialchars($current_collation) . "\n" . ' </dfn>' . "\n" . ' </td>' . "\n"; } echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' ' . $current['tbl_cnt'] . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' ' . $data_size . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' ' . $data_unit . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' ' . $idx_size . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' ' . $idx_unit . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' <b>' . "\n" . ' ' . $tot_size . "\n" . ' </b>' . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' <b>' . "\n" . ' ' . $tot_unit . "\n" . ' </b>' . "\n" . ' </td>' . "\n"; } if ($is_superuser) { echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="center">' . "\n" . ' <a onclick="reload_window(\'' . urlencode($current['db_name']) . '\'); return true;" href="./server_privileges.php?' . $url_query . '&checkprivs=' . urlencode($current['db_name']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['db_name'])) . '">' . "\n" . ' ' . ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" hspace="2" border="0" alt=" ' . $strCheckPrivs . '" /> ' : $strCheckPrivs) . "\n" . ' </a>' . "\n" . ' </td>' . "\n"; } echo ' </tr>' . "\n"; $useBgcolorOne = !$useBgcolorOne; } // end while if (!empty($dbstats)) { list($data_size, $data_unit) = PMA_formatByteDown($total_calc['data_sz'], 3, 1); list($idx_size, $idx_unit) = PMA_formatByteDown($total_calc['idx_sz'], 3, 1); list($tot_size, $tot_unit) = PMA_formatByteDown($total_calc['tot_sz'], 3, 1); echo ' <tr>' . "\n" . ' <th> </th>' . "\n" . ' <th>' . "\n" . ' ' . $strTotalUC . ': ' . $total_calc['db_cnt'] . ' ' . "\n" . ' </th>' . "\n";
/** * Displays the list of tables * * @return void */ protected function displayTableList() { // table form $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status']))); $i = $sum_entries = 0; $overhead_check = ''; $create_time_all = ''; $update_time_all = ''; $check_time_all = ''; $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0; $row_count = 0; $sum_size = (double) 0; $overhead_size = (double) 0; $hidden_fields = array(); $odd_row = true; $overall_approx_rows = false; foreach ($this->_tables as $keyname => $current_table) { // Get valid statistics whatever is the table type $drop_query = ''; $drop_message = ''; $overhead = ''; $table_is_view = false; $table_encoded = urlencode($current_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $this->_url_query . '&table=' . $table_encoded; // do not list the previous table's size info for a view list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size); $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']); if (!$curTable->isMerge()) { $sum_entries += $current_table['TABLE_ROWS']; } if (isset($current_table['Collation'])) { $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>'; } else { $collation = '---'; } if ($this->_is_show_stats) { if ($formatted_overhead != '') { $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span> ' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n"; $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');"; } else { $overhead = '-'; } } // end if $showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true); if ($GLOBALS['cfg']['ShowDbStructureCreation']) { $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : ''; if ($create_time && (!$create_time_all || $create_time < $create_time_all)) { $create_time_all = $create_time; } } if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) { // $showtable might already be set from ShowDbStructureCreation, // see above $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : ''; if ($update_time && (!$update_time_all || $update_time < $update_time_all)) { $update_time_all = $update_time; } } if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) { // $showtable might already be set from ShowDbStructureCreation, // see above $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : ''; if ($check_time && (!$check_time_all || $check_time < $check_time_all)) { $check_time_all = $check_time; } } $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']); $truename = str_replace(' ', ' ', $truename); $i++; $row_count++; if ($table_is_view) { $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />'; } /* * Always activate links for Browse, Search and Empty, even if * the icons are greyed, because * 1. for views, we don't know the number of rows at this point * 2. for tables, another source could have populated them since the * page was generated * * I could have used the PHP ternary conditional operator but I find * the code easier to read without this operator. */ $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view; $titles = Util::buildActionTitles(); $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse'])); $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch'])); $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename)); $empty_table = ''; if (!$this->_db_is_system_schema) { $empty_table = ' '; if (!$table_is_view) { $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty'])); } $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', Util::backquote($current_table['TABLE_NAME'])); $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', ' ', htmlspecialchars($current_table['TABLE_NAME']))); } if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) { $row_count = 1; $odd_row = true; $this->response->addHTML('</tr></tbody></table></form>'); $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status']))); } list($approx_rows, $show_superscript) = $this->isRowCountApproximated($current_table, $table_is_view); list($do, $ignored) = $this->getReplicationStatus($truename); $this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $this->getTrackingIcon($truename), 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME'])))); $odd_row = !$odd_row; $overall_approx_rows = $overall_approx_rows || $approx_rows; } // end foreach $this->response->addHTML('</tbody>'); $db_collation = PMA_getDbCollation($this->db); // Show Summary $this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows))); $this->response->addHTML('</table>'); //check all $this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields))); $this->response->addHTML('</form>'); //end of form }
<td bgcolor="<?php echo $bgcolor; ?> "><?php echo $strCollation; ?> </td> <td bgcolor="<?php echo $bgcolor; ?> " align="<?php echo $cell_align_left; ?> " nowrap="nowrap"> <?php echo '<dfn title="' . PMA_getCollationDescr($tbl_charset) . '">' . $tbl_charset . '</dfn>'; ?> </td> </tr> <?php } if (!$is_innodb && isset($showtable['Rows'])) { $bgcolor = ++$i % 2 ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']; echo "\n"; ?> <tr> <td bgcolor="<?php echo $bgcolor; ?> "><?php echo $strRows;
/** * Index action * * @return void */ public function indexAction() { // Add/Remove favorite tables using Ajax request. if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) { $this->addRemoveFavoriteTablesAction(); return; } $this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js')); // Drops/deletes/etc. multiple tables if required if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) { $action = 'db_structure.php'; $err_url = 'db_structure.php' . PMA_URL_getCommon(array('db' => $this->db)); // see bug #2794840; in this case, code path is: // db_structure.php -> libraries/mult_submits.inc.php -> sql.php // -> db_structure.php and if we got an error on the multi submit, // we must display it here and not call again mult_submits.inc.php if (!isset($_POST['error']) || false === $_POST['error']) { include 'libraries/mult_submits.inc.php'; } if (empty($_POST['message'])) { $_POST['message'] = PMA_Message::success(); } } $this->_url_query .= '&goto=db_structure.php'; // Gets the database structure $sub_part = '_structure'; list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA_Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : ''); $this->_tables = $tables; // updating $tables seems enough for #11376, but updating other // variables too in case they may cause some other problem. $this->_num_tables = $num_tables; $this->_pos = $pos; $this->_db_is_system_schema = $db_is_system_schema; $this->_total_num_tables = $total_num_tables; $this->_is_show_stats = $is_show_stats; // If there is an Ajax request for real row count of a table. if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) { $this->handleRealRowCountRequestAction(); return; } if (!PMA_DRIZZLE) { include_once 'libraries/replication.inc.php'; } else { $GLOBALS['replication_info']['slave']['status'] = false; } PMA_PageSettings::showGroup('DbStructure'); $db_collation = PMA_getDbCollation($this->db); $titles = PMA_Util::buildActionTitles(); // 1. No tables if ($this->_num_tables == 0) { $this->response->addHTML(PMA_message::notice(__('No tables found in database.'))); if (empty($db_is_system_schema)) { $this->response->addHTML(PMA_getHtmlForCreateTable($this->db)); } return; } // else // 2. Shows table information /** * Displays the tables list */ $this->response->addHTML('<div id="tableslistcontainer">'); $_url_params = array('pos' => $this->_pos, 'db' => $this->db); // Add the sort options if they exists if (isset($_REQUEST['sort'])) { $_url_params['sort'] = $_REQUEST['sort']; } if (isset($_REQUEST['sort_order'])) { $_url_params['sort_order'] = $_REQUEST['sort_order']; } $this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList'])); // table form $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db' => $this->db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status']))); $i = $sum_entries = 0; $overhead_check = ''; $create_time_all = ''; $update_time_all = ''; $check_time_all = ''; $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0; $row_count = 0; $sum_size = (double) 0; $overhead_size = (double) 0; $hidden_fields = array(); $odd_row = true; $overall_approx_rows = false; // Instance of PMA_RecentFavoriteTable class. $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite'); foreach ($this->_tables as $keyname => $current_table) { // Get valid statistics whatever is the table type $drop_query = ''; $drop_message = ''; $already_favorite = false; $overhead = ''; $table_is_view = false; $table_encoded = urlencode($current_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $this->_url_query . '&table=' . $table_encoded; // do not list the previous table's size info for a view list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $sum_size, $overhead_size); $curTable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME']); if (!$curTable->isMerge()) { $sum_entries += $current_table['TABLE_ROWS']; } if (isset($current_table['Collation'])) { $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>'; } else { $collation = '---'; } if ($this->_is_show_stats) { if ($formatted_overhead != '') { $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span> ' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n"; $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');"; } else { $overhead = '-'; } } // end if $showtable = $this->dbi->getTable($this->db, $current_table['TABLE_NAME'])->getStatusInfo(null, true); if ($GLOBALS['cfg']['ShowDbStructureCreation']) { $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : ''; if ($create_time && (!$create_time_all || $create_time < $create_time_all)) { $create_time_all = $create_time; } } if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) { // $showtable might already be set from ShowDbStructureCreation, // see above $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : ''; if ($update_time && (!$update_time_all || $update_time < $update_time_all)) { $update_time_all = $update_time; } } if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) { // $showtable might already be set from ShowDbStructureCreation, // see above $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : ''; if ($check_time && (!$check_time_all || $check_time < $check_time_all)) { $check_time_all = $check_time; } } $alias = htmlspecialchars(!empty($tooltip_aliasname) && isset($tooltip_aliasname[$current_table['TABLE_NAME']]) ? $tooltip_aliasname[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']); $alias = str_replace(' ', ' ', $alias); $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']); $truename = str_replace(' ', ' ', $truename); $i++; $row_count++; if ($table_is_view) { $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />'; } /* * Always activate links for Browse, Search and Empty, even if * the icons are greyed, because * 1. for views, we don't know the number of rows at this point * 2. for tables, another source could have populated them since the * page was generated * * I could have used the PHP ternary conditional operator but I find * the code easier to read without this operator. */ $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view; $browse_table = Template::get('database/structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse'])); $search_table = Template::get('database/structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch'])); $browse_table_label = Template::get('database/structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename)); $empty_table = ''; if (!$this->_db_is_system_schema) { $empty_table = ' '; if (!$table_is_view) { $empty_table = Template::get('database/structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty'])); } $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', PMA_Util::backquote($current_table['TABLE_NAME'])); $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', ' ', htmlspecialchars($current_table['TABLE_NAME']))); } $tracking_icon = ''; if (PMA_Tracker::isActive()) { $is_tracked = PMA_Tracker::isTracked($GLOBALS["db"], $truename); if ($is_tracked || PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) { $tracking_icon = Template::get('database/structure/tracking_icon')->render(array('url_query' => $this->_url_query, 'truename' => $truename, 'is_tracked' => $is_tracked)); } } if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) { $row_count = 1; $odd_row = true; $this->response->addHTML('</tr></tbody></table>'); $this->response->addHTML(Template::get('database/structure/table_header')->render(array('db_is_system_schema' => false, 'replication' => $GLOBALS['replication_info']['slave']['status']))); } $do = $ignored = false; if ($GLOBALS['replication_info']['slave']['status']) { $nbServSlaveDoDb = count($GLOBALS['replication_info']['slave']['Do_DB']); $nbServSlaveIgnoreDb = count($GLOBALS['replication_info']['slave']['Ignore_DB']); $searchDoDBInTruename = array_search($truename, $GLOBALS['replication_info']['slave']['Do_DB']); $searchDoDBInDB = array_search($this->db, $GLOBALS['replication_info']['slave']['Do_DB']); $do = strlen($searchDoDBInTruename) > 0 || strlen($searchDoDBInDB) > 0 || $nbServSlaveDoDb == 1 && $nbServSlaveIgnoreDb == 1 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Do_Table'], $truename); $searchDb = array_search($this->db, $GLOBALS['replication_info']['slave']['Ignore_DB']); $searchTable = array_search($truename, $GLOBALS['replication_info']['slave']['Ignore_Table']); $ignored = strlen($searchTable) > 0 || strlen($searchDb) > 0 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Ignore_Table'], $truename); } // Handle favorite table list. ----START---- $already_favorite = $this->checkFavoriteTable($current_table['TABLE_NAME']); if (isset($_REQUEST['remove_favorite'])) { if ($already_favorite) { // If already in favorite list, remove it. $favorite_table = $_REQUEST['favorite_table']; $fav_instance->remove($this->db, $favorite_table); } } if (isset($_REQUEST['add_favorite'])) { if (!$already_favorite) { // Otherwise add to favorite list. $favorite_table = $_REQUEST['favorite_table']; $fav_instance->add($this->db, $favorite_table); } } // Handle favorite table list. ----ENDS---- $show_superscript = ''; // there is a null value in the ENGINE // - when the table needs to be repaired, or // - when it's a view // so ensure that we'll display "in use" below for a table // that needs to be repaired $approx_rows = false; if (isset($current_table['TABLE_ROWS']) && ($current_table['ENGINE'] != null || $table_is_view)) { // InnoDB table: we did not get an accurate row count $approx_rows = !$table_is_view && $current_table['ENGINE'] == 'InnoDB' && !$current_table['COUNTED']; // Drizzle views use FunctionEngine, and the only place where // they are available are I_S and D_D schemas, where we do exact // counting if ($table_is_view && $current_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews'] && $current_table['ENGINE'] != 'FunctionEngine') { $approx_rows = true; $show_superscript = PMA_Util::showHint(PMA_sanitize(sprintf(__('This view has at least this number of ' . 'rows. Please refer to %sdocumentation%s.'), '[doc@cfg_MaxExactCountViews]', '[/doc]'))); } } $this->response->addHTML(Template::get('database/structure/structure_table_row')->render(array('db' => $this->db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $tracking_icon, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME'])))); $odd_row = !$odd_row; $overall_approx_rows = $overall_approx_rows || $approx_rows; } // end foreach // Show Summary $this->response->addHTML('</tbody>'); $this->response->addHTML(Template::get('database/structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows))); $this->response->addHTML('</table>'); //check all $this->response->addHTML(Template::get('database/structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields))); $this->response->addHTML('</form>'); //end of form // display again the table list navigator $this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList'])); $this->response->addHTML('</div><hr />'); /** * Work on the database */ /* DATABASE WORK */ /* Printable view of a table */ $this->response->addHTML(Template::get('database/structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query))); if (empty($db_is_system_schema)) { $this->response->addHTML(PMA_getHtmlForCreateTable($this->db)); } }
/** * Index action * * @return void */ public function indexAction() { // Database structure if ($this->_type == 'db') { // Add/Remove favorite tables using Ajax request. if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['favorite_table'])) { $this->addRemoveFavoriteTables(); return; } $this->response->getHeader()->getScripts()->addFiles(array('db_structure.js', 'tbl_change.js', 'jquery/jquery-ui-timepicker-addon.js')); // Drops/deletes/etc. multiple tables if required if (!empty($_POST['submit_mult']) && isset($_POST['selected_tbl']) || isset($_POST['mult_btn'])) { $action = 'db_structure.php'; $err_url = 'db_structure.php' . PMA_URL_getCommon(array('db' => $this->_db)); // see bug #2794840; in this case, code path is: // db_structure.php -> libraries/mult_submits.inc.php -> sql.php // -> db_structure.php and if we got an error on the multi submit, // we must display it here and not call again mult_submits.inc.php if (!isset($_POST['error']) || false === $_POST['error']) { include 'libraries/mult_submits.inc.php'; } if (empty($_POST['message'])) { $_POST['message'] = PMA_Message::success(); } } $this->_url_query .= '&goto=db_structure.php'; // Gets the database structure $sub_part = '_structure'; // If there is an Ajax request for real row count of a table. if ($GLOBALS['is_ajax_request'] && isset($_REQUEST['real_row_count']) && $_REQUEST['real_row_count'] == true) { $this->handleRealRowCountRequestAction(); return; } if (!PMA_DRIZZLE) { include_once 'libraries/replication.inc.php'; } else { $GLOBALS['replication_info']['slave']['status'] = false; } PMA_PageSettings::showGroup('DbStructure'); $db_collation = PMA_getDbCollation($this->_db); $titles = PMA_Util::buildActionTitles(); // 1. No tables if ($this->_num_tables == 0) { $this->response->addHTML(PMA_message::notice(__('No tables found in database.'))); if (empty($db_is_system_schema)) { $this->response->addHTML(PMA_getHtmlForCreateTable($this->_db)); } return; } // else // 2. Shows table information /** * Displays the tables list */ $this->response->addHTML('<div id="tableslistcontainer">'); $_url_params = array('pos' => $this->_pos, 'db' => $this->_db); // Add the sort options if they exists if (isset($_REQUEST['sort'])) { $_url_params['sort'] = $_REQUEST['sort']; } if (isset($_REQUEST['sort_order'])) { $_url_params['sort_order'] = $_REQUEST['sort_order']; } $this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList'])); // table form $this->response->addHTML(Template::get('structure/table_header')->render(array('db' => $this->_db, 'db_is_system_schema' => $this->_db_is_system_schema, 'replication' => $GLOBALS['replication_info']['slave']['status']))); $i = $sum_entries = 0; $overhead_check = ''; $create_time_all = ''; $update_time_all = ''; $check_time_all = ''; $num_columns = $GLOBALS['cfg']['PropertiesNumColumns'] > 1 ? ceil($this->_num_tables / $GLOBALS['cfg']['PropertiesNumColumns']) + 1 : 0; $row_count = 0; $sum_size = (double) 0; $overhead_size = (double) 0; $hidden_fields = array(); $odd_row = true; $overall_approx_rows = false; // Instance of PMA_RecentFavoriteTable class. $fav_instance = PMA_RecentFavoriteTable::getInstance('favorite'); foreach ($this->_tables as $keyname => $current_table) { // Get valid statistics whatever is the table type $drop_query = ''; $drop_message = ''; $already_favorite = false; $overhead = ''; $table_is_view = false; $table_encoded = urlencode($current_table['TABLE_NAME']); // Sets parameters for links $tbl_url_query = $this->_url_query . '&table=' . $table_encoded; // do not list the previous table's size info for a view list($current_table, $formatted_size, $unit, $formatted_overhead, $overhead_unit, $overhead_size, $table_is_view, $sum_size) = $this->getStuffForEngineTypeTable($current_table, $this->_db_is_system_schema, $this->_is_show_stats, $sum_size, $overhead_size); if (!$this->dbi->getTable($this->_db, $current_table['TABLE_NAME'])->isMerge()) { $sum_entries += $current_table['TABLE_ROWS']; } if (isset($current_table['Collation'])) { $collation = '<dfn title="' . PMA_getCollationDescr($current_table['Collation']) . '">' . $current_table['Collation'] . '</dfn>'; } else { $collation = '---'; } if ($this->_is_show_stats) { if ($formatted_overhead != '') { $overhead = '<a href="tbl_structure.php' . $tbl_url_query . '#showusage">' . '<span>' . $formatted_overhead . '</span> ' . '<span class="unit">' . $overhead_unit . '</span>' . '</a>' . "\n"; $overhead_check .= "markAllRows('row_tbl_" . ($i + 1) . "');"; } else { $overhead = '-'; } } // end if $showtable = $this->dbi->getTable($this->_db, $current_table['TABLE_NAME'])->sGetStatusInfo(null, true); if ($GLOBALS['cfg']['ShowDbStructureCreation']) { $create_time = isset($showtable['Create_time']) ? $showtable['Create_time'] : ''; if ($create_time && (!$create_time_all || $create_time < $create_time_all)) { $create_time_all = $create_time; } } if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) { // $showtable might already be set from ShowDbStructureCreation, // see above $update_time = isset($showtable['Update_time']) ? $showtable['Update_time'] : ''; if ($update_time && (!$update_time_all || $update_time < $update_time_all)) { $update_time_all = $update_time; } } if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) { // $showtable might already be set from ShowDbStructureCreation, // see above $check_time = isset($showtable['Check_time']) ? $showtable['Check_time'] : ''; if ($check_time && (!$check_time_all || $check_time < $check_time_all)) { $check_time_all = $check_time; } } $alias = htmlspecialchars(!empty($tooltip_aliasname) && isset($tooltip_aliasname[$current_table['TABLE_NAME']]) ? $tooltip_aliasname[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']); $alias = str_replace(' ', ' ', $alias); $truename = htmlspecialchars(!empty($tooltip_truename) && isset($tooltip_truename[$current_table['TABLE_NAME']]) ? $tooltip_truename[$current_table['TABLE_NAME']] : $current_table['TABLE_NAME']); $truename = str_replace(' ', ' ', $truename); $i++; $row_count++; if ($table_is_view) { $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />'; } /* * Always activate links for Browse, Search and Empty, even if * the icons are greyed, because * 1. for views, we don't know the number of rows at this point * 2. for tables, another source could have populated them since the * page was generated * * I could have used the PHP ternary conditional operator but I find * the code easier to read without this operator. */ $may_have_rows = $current_table['TABLE_ROWS'] > 0 || $table_is_view; $browse_table = Template::get('structure/browse_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Browse'] : $titles['NoBrowse'])); $search_table = Template::get('structure/search_table')->render(array('tbl_url_query' => $tbl_url_query, 'title' => $may_have_rows ? $titles['Search'] : $titles['NoSearch'])); $browse_table_label = Template::get('structure/browse_table_label')->render(array('tbl_url_query' => $tbl_url_query, 'title' => htmlspecialchars($current_table['TABLE_COMMENT']), 'truename' => $truename)); $empty_table = ''; if (!$this->_db_is_system_schema) { $empty_table = ' '; if (!$table_is_view) { $empty_table = Template::get('structure/empty_table')->render(array('tbl_url_query' => $tbl_url_query, 'sql_query' => urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME'])), 'message_to_show' => urlencode(sprintf(__('Table %s has been emptied.'), htmlspecialchars($current_table['TABLE_NAME']))), 'title' => $may_have_rows ? $titles['Empty'] : $titles['NoEmpty'])); } $drop_query = sprintf('DROP %s %s', $table_is_view || $current_table['ENGINE'] == null ? 'VIEW' : 'TABLE', PMA_Util::backquote($current_table['TABLE_NAME'])); $drop_message = sprintf($table_is_view || $current_table['ENGINE'] == null ? __('View %s has been dropped.') : __('Table %s has been dropped.'), str_replace(' ', ' ', htmlspecialchars($current_table['TABLE_NAME']))); } $tracking_icon = ''; if (PMA_Tracker::isActive()) { $is_tracked = PMA_Tracker::isTracked($GLOBALS["db"], $truename); if ($is_tracked || PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) { $tracking_icon = Template::get('structure/tracking_icon')->render(array('url_query' => $this->_url_query, 'truename' => $truename, 'is_tracked' => $is_tracked)); } } if ($num_columns > 0 && $this->_num_tables > $num_columns && $row_count % $num_columns == 0) { $row_count = 1; $odd_row = true; $this->response->addHTML('</tr></tbody></table>'); $this->response->addHTML(Template::get('structure/table_header')->render(array('db_is_system_schema' => false, 'replication' => $GLOBALS['replication_info']['slave']['status']))); } $do = $ignored = false; $server_slave_status = $GLOBALS['replication_info']['slave']['status']; include_once 'libraries/replication.inc.php'; if ($server_slave_status) { $nbServSlaveDoDb = count($GLOBALS['replication_info']['slave']['Do_DB']); $nbServSlaveIgnoreDb = count($GLOBALS['replication_info']['slave']['Ignore_DB']); $searchDoDBInTruename = array_search($truename, $GLOBALS['replication_info']['slave']['Do_DB']); $searchDoDBInDB = array_search($this->_db, $GLOBALS['replication_info']['slave']['Do_DB']); $do = strlen($searchDoDBInTruename) > 0 || strlen($searchDoDBInDB) > 0 || $nbServSlaveDoDb == 1 && $nbServSlaveIgnoreDb == 1 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Do_Table'], $truename); $searchDb = array_search($this->_db, $GLOBALS['replication_info']['slave']['Ignore_DB']); $searchTable = array_search($truename, $GLOBALS['replication_info']['slave']['Ignore_Table']); $ignored = strlen($searchTable) > 0 || strlen($searchDb) > 0 || $this->hasTable($GLOBALS['replication_info']['slave']['Wild_Ignore_Table'], $truename); } // Handle favorite table list. ----START---- $already_favorite = $this->checkFavoriteTable($current_table['TABLE_NAME']); if (isset($_REQUEST['remove_favorite'])) { if ($already_favorite) { // If already in favorite list, remove it. $favorite_table = $_REQUEST['favorite_table']; $fav_instance->remove($this->_db, $favorite_table); } } if (isset($_REQUEST['add_favorite'])) { if (!$already_favorite) { // Otherwise add to favorite list. $favorite_table = $_REQUEST['favorite_table']; $fav_instance->add($this->_db, $favorite_table); } } // Handle favorite table list. ----ENDS---- $show_superscript = ''; // there is a null value in the ENGINE // - when the table needs to be repaired, or // - when it's a view // so ensure that we'll display "in use" below for a table // that needs to be repaired $approx_rows = false; if (isset($current_table['TABLE_ROWS']) && ($current_table['ENGINE'] != null || $table_is_view)) { // InnoDB table: we did not get an accurate row count $approx_rows = !$table_is_view && $current_table['ENGINE'] == 'InnoDB' && !$current_table['COUNTED']; // Drizzle views use FunctionEngine, and the only place where // they are available are I_S and D_D schemas, where we do exact // counting if ($table_is_view && $current_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews'] && $current_table['ENGINE'] != 'FunctionEngine') { $approx_rows = true; $show_superscript = PMA_Util::showHint(PMA_sanitize(sprintf(__('This view has at least this number of ' . 'rows. Please refer to %sdocumentation%s.'), '[doc@cfg_MaxExactCountViews]', '[/doc]'))); } } $this->response->addHTML(Template::get('structure/structure_table_row')->render(array('db' => $this->_db, 'curr' => $i, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $tracking_icon, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $this->_db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => isset($create_time) ? $create_time : '', 'update_time' => isset($update_time) ? $update_time : '', 'check_time' => isset($check_time) ? $check_time : '', 'is_show_stats' => $this->_is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $GLOBALS['colspan_for_structure'], 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript, 'already_favorite' => $this->checkFavoriteTable($current_table['TABLE_NAME'])))); $odd_row = !$odd_row; $overall_approx_rows = $overall_approx_rows || $approx_rows; } // end foreach // Show Summary $this->response->addHTML('</tbody>'); $this->response->addHTML(Template::get('structure/body_for_table_summary')->render(array('num_tables' => $this->_num_tables, 'server_slave_status' => $GLOBALS['replication_info']['slave']['status'], 'db_is_system_schema' => $this->_db_is_system_schema, 'sum_entries' => $sum_entries, 'db_collation' => $db_collation, 'is_show_stats' => $this->_is_show_stats, 'sum_size' => $sum_size, 'overhead_size' => $overhead_size, 'create_time_all' => $create_time_all, 'update_time_all' => $update_time_all, 'check_time_all' => $check_time_all, 'approx_rows' => $overall_approx_rows))); $this->response->addHTML('</table>'); //check all $this->response->addHTML(Template::get('structure/check_all_tables')->render(array('pmaThemeImage' => $GLOBALS['pmaThemeImage'], 'text_dir' => $GLOBALS['text_dir'], 'overhead_check' => $overhead_check, 'db_is_system_schema' => $this->_db_is_system_schema, 'hidden_fields' => $hidden_fields))); $this->response->addHTML('</form>'); //end of form // display again the table list navigator $this->response->addHTML(PMA_Util::getListNavigator($this->_total_num_tables, $this->_pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList'])); $this->response->addHTML('</div><hr />'); /** * Work on the database */ /* DATABASE WORK */ /* Printable view of a table */ $this->response->addHTML(Template::get('structure/print_view_data_dictionary_link')->render(array('url_query' => $this->_url_query))); if (empty($db_is_system_schema)) { $this->response->addHTML(PMA_getHtmlForCreateTable($this->_db)); } } elseif ($this->_type == 'table') { // Table structure PMA_PageSettings::showGroup('TableStructure'); /** * Function implementations for this script */ require_once 'libraries/check_user_privileges.lib.php'; require_once 'libraries/index.lib.php'; require_once 'libraries/sql.lib.php'; require_once 'libraries/bookmark.lib.php'; $this->response->getHeader()->getScripts()->addFiles(array('tbl_structure.js', 'indexes.js')); /** * Handle column moving */ if (isset($_REQUEST['move_columns']) && is_array($_REQUEST['move_columns']) && $this->response->isAjax()) { $this->moveColumns(); return; } /** * handle MySQL reserved words columns check */ if (isset($_REQUEST['reserved_word_check'])) { if ($GLOBALS['cfg']['ReservedWordDisableWarning'] === false) { $columns_names = $_REQUEST['field_name']; $reserved_keywords_names = array(); foreach ($columns_names as $column) { if (SqlParser\Context::isKeyword(trim($column), true)) { $reserved_keywords_names[] = trim($column); } } if (SqlParser\Context::isKeyword(trim($this->_table), true)) { $reserved_keywords_names[] = trim($this->_table); } if (count($reserved_keywords_names) == 0) { $this->response->isSuccess(false); } $this->response->addJSON('message', sprintf(_ngettext('The name \'%s\' is a MySQL reserved keyword.', 'The names \'%s\' are MySQL reserved keywords.', count($reserved_keywords_names)), implode(',', $reserved_keywords_names))); } else { $this->response->isSuccess(false); } return; } /** * A click on Change has been made for one column */ if (isset($_REQUEST['change_column'])) { $this->displayHtmlForColumnChange(null, 'tbl_structure.php'); return; } /** * handle multiple field commands if required * * submit_mult_*_x comes from IE if <input type="img" ...> is used */ $submit_mult = $this->getMultipleFieldCommandType(); if (!empty($submit_mult)) { if (isset($_REQUEST['selected_fld'])) { if ($submit_mult == 'browse') { // browsing the table displaying only selected columns $this->displayTableBrowseForSelectedColumns($GLOBALS['goto'], $GLOBALS['pmaThemeImage']); } else { // handle multiple field commands // handle confirmation of deleting multiple columns $action = 'tbl_structure.php'; $GLOBALS['selected'] = $_REQUEST['selected_fld']; list($what_ret, $query_type_ret, $is_unset_submit_mult, $mult_btn_ret, $centralColsError) = $this->getDataForSubmitMult($submit_mult, $_REQUEST['selected_fld'], $action); //update the existing variables // todo: refactor mult_submits.inc.php such as // below globals are not needed anymore if (isset($what_ret)) { $GLOBALS['what'] = $what_ret; global $what; } if (isset($query_type_ret)) { $GLOBALS['query_type'] = $query_type_ret; global $query_type; } if ($is_unset_submit_mult) { unset($submit_mult); } if (isset($mult_btn_ret)) { $GLOBALS['mult_btn'] = $mult_btn_ret; global $mult_btn; } include 'libraries/mult_submits.inc.php'; /** * if $submit_mult == 'change', execution will have stopped * at this point */ if (empty($message)) { $message = PMA_Message::success(); } $this->response->addHTML(PMA_Util::getMessage($message, $sql_query)); } } else { $this->response->isSuccess(false); $this->response->addJSON('message', __('No column selected.')); } } // display secondary level tabs if necessary $engine = $this->_table_obj->sGetStatusInfo('ENGINE'); $this->response->addHTML(Template::get('structure/secondary_tabs')->render(array('url_params' => array('db' => $this->_db, 'table' => $this->_table), 'engine' => $engine))); $this->response->addHTML('<div id="structure_content">'); /** * Modifications have been submitted -> updates the table */ if (isset($_REQUEST['do_save_data'])) { $regenerate = $this->updateColumns(); if ($regenerate) { // This happens when updating failed // @todo: do something appropriate } else { // continue to show the table's structure unset($_REQUEST['selected']); } } /** * Adding indexes */ if (isset($_REQUEST['add_key'])) { //todo: set some variables for sql.php include, to be eliminated //after refactoring sql.php $db = $this->_db; $table = $this->_table; $cfg = $GLOBALS['cfg']; $is_superuser = $GLOBALS['dbi']->isSuperuser(); $pmaThemeImage = $GLOBALS['pmaThemeImage']; include 'sql.php'; $GLOBALS['reload'] = true; } /** * Gets the relation settings */ $cfgRelation = PMA_getRelationsParam(); /** * Runs common work */ // set db, table references, for require_once that follows // got to be eliminated in long run $db =& $this->_db; $table =& $this->_table; require_once 'libraries/tbl_common.inc.php'; $this->_url_query = $url_query . '&goto=tbl_structure.php&back=tbl_structure.php'; $url_params['goto'] = 'tbl_structure.php'; $url_params['back'] = 'tbl_structure.php'; /** * Gets tables information */ 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($this->_table, $this->_db); $columns_with_index = $this->dbi->getTable($this->_db, $this->_table)->getColumnsWithIndex(PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL | PMA_Index::FULLTEXT); $columns_with_unique_index = $this->dbi->getTable($this->_db, $this->_table)->getColumnsWithIndex(PMA_Index::UNIQUE); // 3. Get fields $fields = (array) $this->dbi->getColumns($this->_db, $this->_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 = $this->_table_obj->showCreate(); $parser = new SqlParser\Parser($show_create_table); /** * @var CreateStatement $stmt */ $stmt = $parser->statements[0]; $create_table_fields = SqlParser\Utils\Table::getFields($stmt); //display table structure $this->response->addHTML($this->displayStructure($cfgRelation, $columns_with_unique_index, $url_params, $primary, $fields, $columns_with_index, $create_table_fields)); $this->response->addHTML('</div>'); } }