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';
16 $GLOBALS['js_include'][] = 'tbl_structure.js';
19 * handle multiple field commands if required
21 * submit_mult_*_x comes from IE if <input type="img" ...> is used
23 if (isset($_REQUEST['submit_mult_change_x'])) {
24 $submit_mult = __('Change');
25 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
26 $submit_mult = __('Drop');
27 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
28 $submit_mult = __('Primary');
29 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
30 $submit_mult = __('Index');
31 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
32 $submit_mult = __('Unique');
33 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
34 $submit_mult = __('Fulltext');
35 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
36 $submit_mult = __('Browse');
37 } elseif (isset($_REQUEST['submit_mult'])) {
38 $submit_mult = $_REQUEST['submit_mult'];
39 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) {
40 $submit_mult = 'row_delete';
41 if (isset($_REQUEST['selected'])) {
42 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
46 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
47 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
48 if ($submit_mult == __('Browse')) {
49 // browsing the table displaying only selected fields/columns
50 $GLOBALS['active_page'] = 'sql.php';
52 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
53 if ($sql_query == '') {
54 $sql_query .= 'SELECT ' . PMA_backquote($sval);
56 $sql_query .= ', ' . PMA_backquote($sval);
60 // what is this htmlspecialchars() for??
61 //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
62 $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
66 // handle multiple field commands
67 // handle confirmation of deleting multiple fields/columns
68 $action = 'tbl_structure.php';
69 require './libraries/mult_submits.inc.php';
70 //require_once './libraries/header.inc.php';
71 //require_once './libraries/tbl_links.inc.php';
73 if (empty($message)) {
74 $message = PMA_Message
::success();
80 * Gets the relation settings
82 $cfgRelation = PMA_getRelationsParam();
87 require_once './libraries/tbl_common.php';
88 $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php';
89 $url_params['goto'] = 'tbl_structure.php';
90 $url_params['back'] = 'tbl_structure.php';
93 * Prepares the table structure display
98 * Gets tables informations
100 require_once './libraries/tbl_info.inc.php';
103 * Displays top menu links
105 require_once './libraries/tbl_links.inc.php';
106 require_once './libraries/Index.class.php';
108 // 2. Gets table keys and retains them
109 // @todo should be: $server->db($db)->table($table)->primary()
110 $primary = PMA_Index
::getPrimary($table, $db);
112 $columns_with_unique_index = array();
113 foreach (PMA_Index
::getFromTable($table, $db) as $index) {
114 if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
115 $columns = $index->getColumns();
116 foreach ($columns as $column_name => $dummy) {
117 $columns_with_unique_index[$column_name] = 1;
121 unset($index, $columns, $column_name, $dummy);
124 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
125 $fields_cnt = PMA_DBI_num_rows($fields_rs);
128 // Get more complete field information
129 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
130 // but later, if the analyser returns more information, it
131 // could be executed for any MySQL version and replace
132 // the info given by SHOW FULL FIELDS FROM.
134 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
135 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
136 // and SHOW CREATE TABLE says NOT NULL (tested
137 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
139 $show_create_table = PMA_DBI_fetch_value(
140 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
142 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
145 * prepare table infos
147 // action titles (image or string)
149 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
150 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
151 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
152 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
153 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
154 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
155 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
156 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
157 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
158 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
159 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
160 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
162 // hidden action titles (image and string)
163 $hidden_titles = array();
164 $hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), false, true);
165 $hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), false, true);
166 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), false, true);
167 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Index'), false, true);
168 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), false, true);
169 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), false, true);
170 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), false, true);
171 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), false, true);
172 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), false, true);
175 * Displays the table structure ('show table' works correct since 3.23.03)
177 /* TABLE INFORMATION */
181 <form method
="post" action
="tbl_structure.php" name
="fieldsForm" id
="fieldsForm">
182 <?php
echo PMA_generate_common_hidden_inputs($db, $table);
183 echo '<input type="hidden" name="table_type" value=';
184 if($db_is_information_schema) {
185 echo '"information_schema" />';
186 } else if ($tbl_is_view) {
192 <table id
="tablestructure" class="data">
195 <th id
="th<?php echo ++$i; ?>"></th
>
196 <th id
="th<?php echo ++$i; ?>">#</th>
197 <th id
="th<?php echo ++$i; ?>" class="column"><?php
echo __('Column'); ?
></th
>
198 <th id
="th<?php echo ++$i; ?>" class="type"><?php
echo __('Type'); ?
></th
>
199 <th id
="th<?php echo ++$i; ?>" class="collation"><?php
echo __('Collation'); ?
></th
>
200 <th id
="th<?php echo ++$i; ?>" class="attributes"><?php
echo __('Attributes'); ?
></th
>
201 <th id
="th<?php echo ++$i; ?>" class="null"><?php
echo __('Null'); ?
></th
>
202 <th id
="th<?php echo ++$i; ?>" class="default"><?php
echo __('Default'); ?
></th
>
203 <th id
="th<?php echo ++$i; ?>" class="extra"><?php
echo __('Extra'); ?
></th
>
204 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
205 <th id
="th<?php echo ++$i; ?>" class="view"><?php
echo __('View'); ?
></th
>
207 <th colspan
="7" id
="th<?php echo ++$i; ?>" class="action"><?php
echo __('Action'); ?
></th
>
219 $comments_map = array();
222 if ($GLOBALS['cfg']['ShowPropertyComments']) {
223 require_once './libraries/transformations.lib.php';
225 //$cfgRelation = PMA_getRelationsParam();
227 $comments_map = PMA_getComments($db, $table);
229 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
230 $mime_map = PMA_getMIME($db, $table, true);
235 $aryFields = array();
236 $checked = (!empty($checkall) ?
' checked="checked"' : '');
239 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
242 $aryFields[] = $row['Field'];
244 $type = $row['Type'];
245 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
247 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
248 $type = $extracted_fieldspec['type'] . '(' .
249 str_replace("','", "', '", $extracted_fieldspec['spec_in_brackets']) . ')';
251 // for the case ENUM('–','“')
252 $type = htmlspecialchars($type);
253 if(strlen($type) > $GLOBALS['cfg']['LimitChars']) {
254 $type = '<abbr title="full text">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
263 $type_nowrap = ' nowrap="nowrap"';
264 // strip the "BINARY" attribute, except if we find "BINARY(" because
265 // this would be a BINARY or VARBINARY field type
266 if (!preg_match('@BINARY[\(]@i', $type)) {
267 $type = preg_replace('@BINARY@i', '', $type);
269 $type = preg_replace('@ZEROFILL@i', '', $type);
270 $type = preg_replace('@UNSIGNED@i', '', $type);
275 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
276 $binary = stristr($row['Type'], 'blob') ||
stristr($row['Type'], 'binary');
281 $unsigned = stristr($row['Type'], 'unsigned');
282 $zerofill = stristr($row['Type'], 'zerofill');
285 unset($field_charset);
286 if ((substr($type, 0, 4) == 'char'
287 ||
substr($type, 0, 7) == 'varchar'
288 ||
substr($type, 0, 4) == 'text'
289 ||
substr($type, 0, 8) == 'tinytext'
290 ||
substr($type, 0, 10) == 'mediumtext'
291 ||
substr($type, 0, 8) == 'longtext'
292 ||
substr($type, 0, 3) == 'set'
293 ||
substr($type, 0, 4) == 'enum'
295 if (strpos($type, ' character set ')) {
296 $type = substr($type, 0, strpos($type, ' character set '));
298 if (!empty($row['Collation'])) {
299 $field_charset = $row['Collation'];
307 // Display basic mimetype [MIME]
308 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
309 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
316 $attribute = 'BINARY';
319 $attribute = 'UNSIGNED';
322 $attribute = 'UNSIGNED ZEROFILL';
325 // MySQL 4.1.2+ TIMESTAMP options
326 // (if on_update_current_timestamp is set, then it's TRUE)
327 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
328 $attribute = 'on update CURRENT_TIMESTAMP';
331 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
332 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
334 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']) {
339 if (!isset($row['Default'])) {
340 if ($row['Null'] == 'YES') {
341 $row['Default'] = '<i>NULL</i>';
344 $row['Default'] = htmlspecialchars($row['Default']);
347 $field_encoded = urlencode($row['Field']);
348 $field_name = htmlspecialchars($row['Field']);
349 $displayed_field_name = $field_name;
351 // underline commented fields and display a hover-title (CSS only)
353 if (isset($comments_map[$row['Field']])) {
354 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
357 if ($primary && $primary->hasColumn($field_name)) {
358 $displayed_field_name = '<u>' . $field_name . '</u>';
362 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
364 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo htmlspecialchars($row['Field']); ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
367 <?php
echo $rownum; ?
>
369 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $displayed_field_name; ?
></label
></th
>
370 <td
<?php
echo $type_nowrap; ?
>><bdo dir
="ltr" xml
:lang
="en"><?php
echo $type; echo $type_mime; ?
></bdo
></td
>
371 <td
><?php
echo (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?
></td
>
372 <td nowrap
="nowrap" class="column_attribute"><?php
echo $attribute; ?
></td
>
373 <td
><?php
echo (($row['Null'] == 'YES') ?
__('Yes') : __('No')); ?
></td
>
374 <td nowrap
="nowrap"><?php
375 if (isset($row['Default'])) {
376 if ($extracted_fieldspec['type'] == 'bit') {
377 // here, $row['Default'] contains something like b'010'
378 echo PMA_convert_bit_default_value($row['Default']);
380 echo $row['Default'];
384 echo '<i>' . _pgettext('None for default','None') . '</i>';
386 <td nowrap
="nowrap"><?php
echo strtoupper($row['Extra']); ?
></td
>
387 <td align
="center" class="browse">
388 <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'])); ?>">
389 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
391 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
392 <td align
="center" class="edit">
393 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
394 <?php
echo $titles['Change']; ?
></a
>
396 <td align
="center" class="drop">
397 <a
class="drop_column_anchor" href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&dropped_column=<?php echo urlencode($row['Field']); ?>&message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
398 <?php
echo $titles['Drop']; ?
></a
>
400 <td align
="center" class="primary">
402 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
($primary && $primary->hasColumn($field_name))) {
403 echo $titles['NoPrimary'] . "\n";
404 $primary_enabled = false;
408 <a
class="add_primary_key_anchor" 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']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
409 <?php
echo $titles['Primary']; ?
></a
>
410 <?php
$primary_enabled = true;
415 <td align
="center" class="unique">
417 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
isset($columns_with_unique_index[$field_name])) {
418 echo $titles['NoUnique'] . "\n";
419 $unique_enabled = false;
423 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
424 <?php
echo $titles['Unique']; ?
></a
>
425 <?php
$unique_enabled = true;
430 <td align
="center" class="index">
432 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type) {
433 echo $titles['NoIndex'] . "\n";
434 $index_enabled = false;
438 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
439 <?php
echo $titles['Index']; ?
></a
>
441 $index_enabled = true;
447 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')
448 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
449 && (strpos(' ' . $type, 'text') ||
strpos(' ' . $type, 'char'))) {
452 <td align
="center" nowrap
="nowrap" class="fulltext">
453 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
454 <?php
echo $titles['IdxFulltext']; ?
></a
>
455 <?php
$fulltext_enabled = true; ?
>
461 <td align
="center" nowrap
="nowrap" class="fulltext">
462 <?php
echo $titles['NoIdxFulltext'] . "\n"; ?
>
463 <?php
$fulltext_enabled = false; ?
>
466 } // end if... else...
468 } // end if (! $tbl_is_view && ! $db_is_information_schema)
470 <td
class="more_opts" id
="more_opts<?php echo $rownum; ?>">
471 More
<img src
="<?php echo $pmaThemeImage . 'more.png'; ?>" alt
="show more actions" />
472 <div
class="structure_actions_dropdown" id
="row_<?php echo $rownum; ?>">
474 <div
class="action_browse">
475 <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'])); ?>">
476 <?php
echo $hidden_titles['BrowseDistinctValues']; ?
>
479 <div
class="action_primary">
481 if(isset($primary_enabled)) {
482 if($primary_enabled) { ?
>
483 <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']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
484 <?php
echo $hidden_titles['Primary']; ?
>
488 echo $hidden_titles['NoPrimary'];
492 <div
class="action_unique">
494 if(isset($unique_enabled)) {
495 if($unique_enabled) { ?
>
496 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
497 <?php
echo $hidden_titles['Unique']; ?
>
501 echo $hidden_titles['NoUnique'];
505 <div
class="action_index">
507 if(isset($index_enabled)) {
508 if($index_enabled) { ?
>
509 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
510 <?php
echo $hidden_titles['Index']; ?
>
514 echo $hidden_titles['NoIndex'];
518 <div
class="action_fulltext">
520 if(isset($fulltext_enabled)) {
521 if($fulltext_enabled) { ?
>
522 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
523 <?php
echo $hidden_titles['IdxFulltext']; ?
>
527 echo $hidden_titles['NoIdxFulltext'];
535 unset($field_charset);
538 echo '</tbody>' . "\n"
541 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
544 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
545 width
="38" height
="22" alt
="<?php echo __('With selected:'); ?>" />
546 <a href
="<?php echo $checkall_url; ?>&checkall=1"
547 onclick
="if (markAllRows('fieldsForm')) return false;">
548 <?php
echo __('Check All'); ?
></a
>
550 <a href
="<?php echo $checkall_url; ?>"
551 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
552 <?php
echo __('Uncheck All'); ?
></a
>
554 <i
><?php
echo __('With selected:'); ?
></i
>
557 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png');
559 if (! $tbl_is_view && ! $db_is_information_schema) {
560 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png');
561 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png');
562 if ('ARCHIVE' != $tbl_type) {
563 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png');
564 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png');
565 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png');
567 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')) {
568 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png');
580 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
581 if ($cfg['PropertiesIconic']) {
582 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
584 echo __('Print view');
588 if (! $tbl_is_view && ! $db_is_information_schema) {
590 // if internal relations are available, or foreign keys are supported
591 // ($tbl_type comes from libraries/tbl_info.inc.php)
592 if ($cfgRelation['relwork'] ||
PMA_foreignkey_supported($tbl_type)) {
594 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
595 if ($cfg['PropertiesIconic']) {
596 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
598 echo __('Relation view');
603 <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
604 if ($cfg['PropertiesIconic']) {
605 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
607 echo __('Propose table structure');
609 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
612 if(PMA_Tracker
::isActive())
614 echo '<a href="tbl_tracking.php?' . $url_query . '">';
616 if ($cfg['PropertiesIconic'])
618 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
620 echo __('Track table') . '</a>';
625 <form method
="post" action
="tbl_addfield.php"
626 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
628 echo PMA_generate_common_hidden_inputs($db, $table);
629 if ($cfg['PropertiesIconic']) {
630 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
632 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
634 // I tried displaying the drop-down inside the label but with Firefox
635 // the drop-down was blinking
636 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
637 foreach ($aryFields as $fieldname) {
638 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
641 $fieldOptions .= '</select>';
644 'last' => __('At End of Table'),
645 'first' => __('At Beginning of Table'),
646 'after' => sprintf(__('After %s'), '')
648 PMA_display_html_radio('field_where', $choices, 'last', false);
650 unset($fieldOptions, $choices);
652 <input type
="submit" value
="<?php echo __('Go'); ?>" />
654 <iframe
class="IE_hack" scrolling
="no"></iframe
>
660 * If there are more than 20 rows, displays browse/select/insert/empty/drop
663 if ($fields_cnt > 20) {
664 require './libraries/tbl_links.inc.php';
665 } // end if ($fields_cnt > 20)
671 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
675 echo PMA_Index
::getView($table, $db);
678 <form action
="./tbl_indexes.php" method
="post"
679 onsubmit
="return checkFormElementInRange(this, 'idx_num_fields',
680 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
684 echo PMA_generate_common_hidden_inputs($db, $table);
685 echo sprintf(__('Create an index on %s columns'),
686 '<input type="text" size="2" name="added_fields" value="1" />');
688 <input type
="submit" name
="create_index" value
="<?php echo __('Go'); ?>"
689 onclick
="return checkFormElementInRange(this.form,
691 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
699 PMA_generate_slider_effect('tablestatistics', __('Details...'));
702 * Displays Space usage and row statistics
704 // BEGIN - Calc Table Space
705 // Get valid statistics whatever is the table type
706 if ($cfg['ShowStats']) {
707 if (empty($showtable)) {
708 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
712 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
713 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
719 $mergetable = PMA_Table
::isMerge($GLOBALS['db'], $GLOBALS['table']);
721 // this is to display for example 261.2 MiB instead of 268k KiB
724 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
725 if ($mergetable == false) {
726 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
728 // InnoDB returns a huge value in Data_free, do not use it
729 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
730 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
731 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
733 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
735 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
736 if ($table_info_num_rows > 0) {
737 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
744 <a name
="showusage"></a
>
745 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
746 <table id
="tablespaceusage" class="data">
747 <caption
class="tblHeaders"><?php
echo __('Space usage'); ?
></caption
>
750 <th
><?php
echo __('Type'); ?
></th
>
751 <th colspan
="2"><?php
echo __('Usage'); ?
></th
>
755 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
756 <th
class="name"><?php
echo __('Data'); ?
></th
>
757 <td
class="value"><?php
echo $data_size; ?
></td
>
758 <td
class="unit"><?php
echo $data_unit; ?
></td
>
761 if (isset($index_size)) {
763 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
764 <th
class="name"><?php
echo __('Index'); ?
></th
>
765 <td
class="value"><?php
echo $index_size; ?
></td
>
766 <td
class="unit"><?php
echo $index_unit; ?
></td
>
770 if (isset($free_size)) {
772 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
773 <th
class="name"><?php
echo __('Overhead'); ?
></th
>
774 <td
class="value"><?php
echo $free_size; ?
></td
>
775 <td
class="unit"><?php
echo $free_unit; ?
></td
>
777 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
778 <th
class="name"><?php
echo __('Effective'); ?
></th
>
779 <td
class="value"><?php
echo $effect_size; ?
></td
>
780 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
784 if (isset($tot_size) && $mergetable == false) {
786 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
787 <th
class="name"><?php
echo __('Total'); ?
></th
>
788 <td
class="value"><?php
echo $tot_size; ?
></td
>
789 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
793 // Optimize link if overhead
794 if (isset($free_size) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA' ||
$tbl_type == 'BDB')) {
796 <tr
class="tblFooters">
797 <td colspan
="3" align
="center">
798 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
799 if ($cfg['PropertiesIconic']) {
800 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
802 echo __('Optimize table');
815 <table id
="tablerowstats" class="data">
816 <caption
class="tblHeaders"><?php
echo __('Row Statistics'); ?
></caption
>
819 <th
><?php
echo __('Statements'); ?
></th
>
820 <th
><?php
echo __('Value'); ?
></th
>
825 if (isset($showtable['Row_format'])) {
827 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
828 <th
class="name"><?php
echo __('Format'); ?
></th
>
829 <td
class="value"><?php
830 if ($showtable['Row_format'] == 'Fixed') {
832 } elseif ($showtable['Row_format'] == 'Dynamic') {
835 echo $showtable['Row_format'];
841 if (! empty($showtable['Create_options'])) {
843 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
844 <th
class="name"><?php
echo __('Options'); ?
></th
>
845 <td
class="value"><?php
846 if ($showtable['Create_options'] == 'partitioned') {
847 echo __('partitioned');
849 echo $showtable['Create_options'];
855 if (!empty($tbl_collation)) {
857 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
858 <th
class="name"><?php
echo __('Collation'); ?
></th
>
859 <td
class="value"><?php
860 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
865 if (!$is_innodb && isset($showtable['Rows'])) {
867 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
868 <th
class="name"><?php
echo __('Rows'); ?
></th
>
869 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
873 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
875 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
876 <th
class="name"><?php
echo __('Row length'); ?
> ø
;</th
>
877 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
881 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
883 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
884 <th
class="name"><?php
echo __(' Row size '); ?
> ø
;</th
>
885 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
889 if (isset($showtable['Auto_increment'])) {
891 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
892 <th
class="name"><?php
echo __('Next'); ?
> Autoindex
</th
>
893 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
897 if (isset($showtable['Create_time'])) {
899 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
900 <th
class="name"><?php
echo __('Creation'); ?
></th
>
901 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
905 if (isset($showtable['Update_time'])) {
907 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
908 <th
class="name"><?php
echo __('Last update'); ?
></th
>
909 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
913 if (isset($showtable['Check_time'])) {
915 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
916 <th
class="name"><?php
echo __('Last check'); ?
></th
>
917 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
925 <!-- close slider div
-->
930 // END - Calc Table Space
932 require './libraries/tbl_triggers.lib.php';
934 echo '<div class="clearfloat"></div>' . "\n";
937 * Displays the footer
939 require './libraries/footer.inc.php';