2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Displays table structure infos like fields/columns, indexes, size, rows
5 * and allows manipulation of indexes and columns/fields
12 require_once './libraries/common.inc.php';
13 require_once './libraries/mysql_charsets.lib.php';
15 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
18 * handle multiple field commands if required
20 * submit_mult_*_x comes from IE if <input type="img" ...> is used
22 if (isset($_REQUEST['submit_mult_change_x'])) {
23 $submit_mult = __('Change');
24 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
25 $submit_mult = __('Drop');
26 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
27 $submit_mult = __('Primary');
28 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
29 $submit_mult = __('Index');
30 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
31 $submit_mult = __('Unique');
32 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
33 $submit_mult = __('Fulltext');
34 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
35 $submit_mult = __('Browse');
36 } elseif (isset($_REQUEST['submit_mult'])) {
37 $submit_mult = $_REQUEST['submit_mult'];
38 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) {
39 $submit_mult = 'row_delete';
40 if (isset($_REQUEST['selected'])) {
41 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
45 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
46 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
47 if ($submit_mult == __('Browse')) {
48 // browsing the table displaying only selected fields/columns
49 $GLOBALS['active_page'] = 'sql.php';
51 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
52 if ($sql_query == '') {
53 $sql_query .= 'SELECT ' . PMA_backquote($sval);
55 $sql_query .= ', ' . PMA_backquote($sval);
59 // what is this htmlspecialchars() for??
60 //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
61 $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
65 // handle multiple field commands
66 // handle confirmation of deleting multiple fields/columns
67 $action = 'tbl_structure.php';
68 require './libraries/mult_submits.inc.php';
69 //require_once './libraries/header.inc.php';
70 //require_once './libraries/tbl_links.inc.php';
72 if (empty($message)) {
73 $message = PMA_Message
::success();
79 * Gets the relation settings
81 $cfgRelation = PMA_getRelationsParam();
86 require_once './libraries/tbl_common.php';
87 $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php';
88 $url_params['goto'] = 'tbl_structure.php';
89 $url_params['back'] = 'tbl_structure.php';
92 * Prepares the table structure display
97 * Gets tables informations
99 require_once './libraries/tbl_info.inc.php';
102 * Displays top menu links
104 require_once './libraries/tbl_links.inc.php';
105 require_once './libraries/Index.class.php';
107 // 2. Gets table keys and retains them
108 // @todo should be: $server->db($db)->table($table)->primary()
109 $primary = PMA_Index
::getPrimary($table, $db);
111 $columns_with_unique_index = array();
112 foreach (PMA_Index
::getFromTable($table, $db) as $index) {
113 if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
114 $columns = $index->getColumns();
115 foreach ($columns as $column_name => $dummy) {
116 $columns_with_unique_index[$column_name] = 1;
120 unset($index, $columns, $column_name, $dummy);
123 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
124 $fields_cnt = PMA_DBI_num_rows($fields_rs);
127 // Get more complete field information
128 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
129 // but later, if the analyser returns more information, it
130 // could be executed for any MySQL version and replace
131 // the info given by SHOW FULL FIELDS FROM.
133 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
134 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
135 // and SHOW CREATE TABLE says NOT NULL (tested
136 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
138 $show_create_table = PMA_DBI_fetch_value(
139 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
141 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
144 * prepare table infos
146 // action titles (image or string)
148 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
149 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
150 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
151 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
152 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
153 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
154 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
155 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
156 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
157 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
158 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
159 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
162 * Displays the table structure ('show table' works correct since 3.23.03)
164 /* TABLE INFORMATION */
168 <form method
="post" action
="tbl_structure.php" name
="fieldsForm" id
="fieldsForm">
169 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
170 <table id
="tablestructure" class="data">
173 <th id
="th<?php echo ++$i; ?>"></th
>
174 <th id
="th<?php echo ++$i; ?>">#</th>
175 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Column'); ?
></th
>
176 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Type'); ?
></th
>
177 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Collation'); ?
></th
>
178 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Attributes'); ?
></th
>
179 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Null'); ?
></th
>
180 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Default'); ?
></th
>
181 <th id
="th<?php echo ++$i; ?>"><?php
echo __('Extra'); ?
></th
>
182 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
183 <th id
="th<?php echo ++$i; ?>"><?php
echo __('View'); ?
></th
>
185 <th colspan
="7" id
="th<?php echo ++$i; ?>"><?php
echo __('Action'); ?
></th
>
197 $comments_map = array();
200 if ($GLOBALS['cfg']['ShowPropertyComments']) {
201 require_once './libraries/transformations.lib.php';
203 //$cfgRelation = PMA_getRelationsParam();
205 $comments_map = PMA_getComments($db, $table);
207 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
208 $mime_map = PMA_getMIME($db, $table, true);
213 $aryFields = array();
214 $checked = (!empty($checkall) ?
' checked="checked"' : '');
217 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
220 $aryFields[] = $row['Field'];
222 $type = $row['Type'];
223 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
225 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
226 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
228 // for the case ENUM('–','“')
229 $type = htmlspecialchars($type);
237 $type_nowrap = ' nowrap="nowrap"';
238 // strip the "BINARY" attribute, except if we find "BINARY(" because
239 // this would be a BINARY or VARBINARY field type
240 if (!preg_match('@BINARY[\(]@i', $type)) {
241 $type = preg_replace('@BINARY@i', '', $type);
243 $type = preg_replace('@ZEROFILL@i', '', $type);
244 $type = preg_replace('@UNSIGNED@i', '', $type);
249 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
250 $binary = stristr($row['Type'], 'blob') ||
stristr($row['Type'], 'binary');
255 $unsigned = stristr($row['Type'], 'unsigned');
256 $zerofill = stristr($row['Type'], 'zerofill');
259 unset($field_charset);
260 if ((substr($type, 0, 4) == 'char'
261 ||
substr($type, 0, 7) == 'varchar'
262 ||
substr($type, 0, 4) == 'text'
263 ||
substr($type, 0, 8) == 'tinytext'
264 ||
substr($type, 0, 10) == 'mediumtext'
265 ||
substr($type, 0, 8) == 'longtext'
266 ||
substr($type, 0, 3) == 'set'
267 ||
substr($type, 0, 4) == 'enum'
269 if (strpos($type, ' character set ')) {
270 $type = substr($type, 0, strpos($type, ' character set '));
272 if (!empty($row['Collation'])) {
273 $field_charset = $row['Collation'];
281 // Display basic mimetype [MIME]
282 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
283 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
290 $attribute = 'BINARY';
293 $attribute = 'UNSIGNED';
296 $attribute = 'UNSIGNED ZEROFILL';
299 // MySQL 4.1.2+ TIMESTAMP options
300 // (if on_update_current_timestamp is set, then it's TRUE)
301 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
302 $attribute = 'on update CURRENT_TIMESTAMP';
305 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
306 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
308 if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
313 if (!isset($row['Default'])) {
314 if ($row['Null'] == 'YES') {
315 $row['Default'] = '<i>NULL</i>';
318 $row['Default'] = htmlspecialchars($row['Default']);
321 $field_encoded = urlencode($row['Field']);
322 $field_name = htmlspecialchars($row['Field']);
323 $displayed_field_name = $field_name;
325 // underline commented fields and display a hover-title (CSS only)
327 if (isset($comments_map[$row['Field']])) {
328 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
331 if ($primary && $primary->hasColumn($field_name)) {
332 $displayed_field_name = '<u>' . $field_name . '</u>';
336 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
338 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo htmlspecialchars($row['Field']); ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
341 <?php
echo $rownum; ?
>
343 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $displayed_field_name; ?
></label
></th
>
344 <td
<?php
echo $type_nowrap; ?
>><bdo dir
="ltr" xml
:lang
="en"><?php
echo $type; echo $type_mime; ?
></bdo
></td
>
345 <td
><?php
echo (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?
></td
>
346 <td nowrap
="nowrap" class="column_attribute"><?php
echo $attribute; ?
></td
>
347 <td
><?php
echo (($row['Null'] == 'YES') ?
__('Yes') : __('No')); ?
></td
>
348 <td nowrap
="nowrap"><?php
349 if (isset($row['Default'])) {
350 if ($extracted_fieldspec['type'] == 'bit') {
351 // here, $row['Default'] contains something like b'010'
352 echo PMA_convert_bit_default_value($row['Default']);
354 echo $row['Default'];
358 echo '<i>' . _pgettext('None for default','None') . '</i>';
360 <td nowrap
="nowrap"><?php
echo strtoupper($row['Extra']); ?
></td
>
362 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
363 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
365 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
367 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
368 <?php
echo $titles['Change']; ?
></a
>
371 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&cpurge=1&purgekey=<?php echo urlencode($row['Field']); ?>&zero_rows=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>"
372 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
373 <?php
echo $titles['Drop']; ?
></a
>
377 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
($primary && $primary->hasColumn($field_name))) {
378 echo $titles['NoPrimary'] . "\n";
382 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>"
383 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
384 <?php
echo $titles['Primary']; ?
></a
>
392 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
isset($columns_with_unique_index[$field_name])) {
393 echo $titles['NoUnique'] . "\n";
397 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
398 <?php
echo $titles['Unique']; ?
></a
>
406 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type) {
407 echo $titles['NoIndex'] . "\n";
411 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
412 <?php
echo $titles['Index']; ?
></a
>
419 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')
420 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
421 && (strpos(' ' . $type, 'text') ||
strpos(' ' . $type, 'char'))) {
424 <td align
="center" nowrap
="nowrap">
425 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
426 <?php
echo $titles['IdxFulltext']; ?
></a
>
432 <td align
="center" nowrap
="nowrap">
433 <?php
echo $titles['NoIdxFulltext'] . "\n"; ?
>
436 } // end if... else...
438 } // end if (! $tbl_is_view && ! $db_is_information_schema)
442 unset($field_charset);
445 echo '</tbody>' . "\n"
448 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
451 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
452 width
="38" height
="22" alt
="<?php echo __('With selected:'); ?>" />
453 <a href
="<?php echo $checkall_url; ?>&checkall=1"
454 onclick
="if (markAllRows('fieldsForm')) return false;">
455 <?php
echo __('Check All'); ?
></a
>
457 <a href
="<?php echo $checkall_url; ?>"
458 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
459 <?php
echo __('Uncheck All'); ?
></a
>
461 <i
><?php
echo __('With selected:'); ?
></i
>
464 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png');
466 if (! $tbl_is_view && ! $db_is_information_schema) {
467 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png');
468 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png');
469 if ('ARCHIVE' != $tbl_type) {
470 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png');
471 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png');
472 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png');
474 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')) {
475 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png');
487 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
488 if ($cfg['PropertiesIconic']) {
489 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
491 echo __('Print view');
495 if (! $tbl_is_view && ! $db_is_information_schema) {
497 // if internal relations are available, or foreign keys are supported
498 // ($tbl_type comes from libraries/tbl_info.inc.php)
499 if ($cfgRelation['relwork'] ||
PMA_foreignkey_supported($tbl_type)) {
501 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
502 if ($cfg['PropertiesIconic']) {
503 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
505 echo __('Relation view');
510 <a href
="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
511 if ($cfg['PropertiesIconic']) {
512 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
514 echo __('Propose table structure');
516 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
519 if(PMA_Tracker
::isActive())
521 echo '<a href="tbl_tracking.php?' . $url_query . '">';
523 if ($cfg['PropertiesIconic'])
525 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
527 echo __('Track table') . '</a>';
532 <form method
="post" action
="tbl_addfield.php"
533 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
535 echo PMA_generate_common_hidden_inputs($db, $table);
536 if ($cfg['PropertiesIconic']) {
537 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
539 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
541 // I tried displaying the drop-down inside the label but with Firefox
542 // the drop-down was blinking
543 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
544 foreach ($aryFields as $fieldname) {
545 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
548 $fieldOptions .= '</select>';
551 'last' => __('At End of Table'),
552 'first' => __('At Beginning of Table'),
553 'after' => sprintf(__('After %s'), '')
555 PMA_display_html_radio('field_where', $choices, 'last', false);
557 unset($fieldOptions, $choices);
559 <input type
="submit" value
="<?php echo __('Go'); ?>" />
566 * If there are more than 20 rows, displays browse/select/insert/empty/drop
569 if ($fields_cnt > 20) {
570 require './libraries/tbl_links.inc.php';
571 } // end if ($fields_cnt > 20)
577 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
581 echo PMA_Index
::getView($table, $db);
584 <form action
="./tbl_indexes.php" method
="post"
585 onsubmit
="return checkFormElementInRange(this, 'idx_num_fields',
586 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
590 echo PMA_generate_common_hidden_inputs($db, $table);
591 echo sprintf(__('Create an index on %s columns'),
592 '<input type="text" size="2" name="added_fields" value="1" />');
594 <input type
="submit" name
="create_index" value
="<?php echo __('Go'); ?>"
595 onclick
="return checkFormElementInRange(this.form,
597 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
605 PMA_generate_slider_effect('tablestatistics', __('Details...'));
608 * Displays Space usage and row statistics
610 // BEGIN - Calc Table Space
611 // Get valid statistics whatever is the table type
612 if ($cfg['ShowStats']) {
613 if (empty($showtable)) {
614 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
618 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
619 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
625 $mergetable = PMA_Table
::isMerge($GLOBALS['db'], $GLOBALS['table']);
627 // this is to display for example 261.2 MiB instead of 268k KiB
630 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
631 if ($mergetable == false) {
632 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
634 // InnoDB returns a huge value in Data_free, do not use it
635 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
636 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
637 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
639 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
641 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
642 if ($table_info_num_rows > 0) {
643 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
650 <a name
="showusage"></a
>
651 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
652 <table id
="tablespaceusage" class="data">
653 <caption
class="tblHeaders"><?php
echo __('Space usage'); ?
></caption
>
656 <th
><?php
echo __('Type'); ?
></th
>
657 <th colspan
="2"><?php
echo __('Usage'); ?
></th
>
661 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
662 <th
class="name"><?php
echo __('Data'); ?
></th
>
663 <td
class="value"><?php
echo $data_size; ?
></td
>
664 <td
class="unit"><?php
echo $data_unit; ?
></td
>
667 if (isset($index_size)) {
669 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
670 <th
class="name"><?php
echo __('Index'); ?
></th
>
671 <td
class="value"><?php
echo $index_size; ?
></td
>
672 <td
class="unit"><?php
echo $index_unit; ?
></td
>
676 if (isset($free_size)) {
678 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
679 <th
class="name"><?php
echo __('Overhead'); ?
></th
>
680 <td
class="value"><?php
echo $free_size; ?
></td
>
681 <td
class="unit"><?php
echo $free_unit; ?
></td
>
683 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
684 <th
class="name"><?php
echo __('Effective'); ?
></th
>
685 <td
class="value"><?php
echo $effect_size; ?
></td
>
686 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
690 if (isset($tot_size) && $mergetable == false) {
692 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
693 <th
class="name"><?php
echo __('Total'); ?
></th
>
694 <td
class="value"><?php
echo $tot_size; ?
></td
>
695 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
699 // Optimize link if overhead
700 if (isset($free_size) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA' ||
$tbl_type == 'BDB')) {
702 <tr
class="tblFooters">
703 <td colspan
="3" align
="center">
704 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
705 if ($cfg['PropertiesIconic']) {
706 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
708 echo __('Optimize table');
721 <table id
="tablerowstats" class="data">
722 <caption
class="tblHeaders"><?php
echo __('Row Statistics'); ?
></caption
>
725 <th
><?php
echo __('Statements'); ?
></th
>
726 <th
><?php
echo __('Value'); ?
></th
>
731 if (isset($showtable['Row_format'])) {
733 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
734 <th
class="name"><?php
echo __('Format'); ?
></th
>
735 <td
class="value"><?php
736 if ($showtable['Row_format'] == 'Fixed') {
738 } elseif ($showtable['Row_format'] == 'Dynamic') {
741 echo $showtable['Row_format'];
747 if (! empty($showtable['Create_options'])) {
749 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
750 <th
class="name"><?php
echo __('Options'); ?
></th
>
751 <td
class="value"><?php
752 if ($showtable['Create_options'] == 'partitioned') {
753 echo __('partitioned');
755 echo $showtable['Create_options'];
761 if (!empty($tbl_collation)) {
763 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
764 <th
class="name"><?php
echo __('Collation'); ?
></th
>
765 <td
class="value"><?php
766 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
771 if (!$is_innodb && isset($showtable['Rows'])) {
773 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
774 <th
class="name"><?php
echo __('Rows'); ?
></th
>
775 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
779 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
781 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
782 <th
class="name"><?php
echo __('Row length'); ?
> ø
;</th
>
783 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
787 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
789 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
790 <th
class="name"><?php
echo __(' Row size '); ?
> ø
;</th
>
791 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
795 if (isset($showtable['Auto_increment'])) {
797 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
798 <th
class="name"><?php
echo __('Next'); ?
> Autoindex
</th
>
799 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
803 if (isset($showtable['Create_time'])) {
805 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
806 <th
class="name"><?php
echo __('Creation'); ?
></th
>
807 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
811 if (isset($showtable['Update_time'])) {
813 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
814 <th
class="name"><?php
echo __('Last update'); ?
></th
>
815 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
819 if (isset($showtable['Check_time'])) {
821 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
822 <th
class="name"><?php
echo __('Last check'); ?
></th
>
823 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
831 <!-- close slider div
-->
836 // END - Calc Table Space
838 require './libraries/tbl_triggers.lib.php';
840 echo '<div class="clearfloat"></div>' . "\n";
843 * Displays the footer
845 require './libraries/footer.inc.php';