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);
161 // hidden action titles (image and string)
162 $hidden_titles = array();
163 $hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), false, true);
164 $hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), false, true);
165 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), false, true);
166 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Index'), false, true);
167 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), false, true);
168 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), false, true);
169 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), false, true);
170 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), false, true);
171 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), false, true);
174 * Displays the table structure ('show table' works correct since 3.23.03)
176 /* TABLE INFORMATION */
180 <form method
="post" action
="tbl_structure.php" name
="fieldsForm" id
="fieldsForm">
181 <?php
echo PMA_generate_common_hidden_inputs($db, $table);
182 echo '<input type="hidden" name="table_type" value=';
183 if($db_is_information_schema) {
184 echo '"information_schema" />';
185 } else if ($tbl_is_view) {
191 <table id
="tablestructure" class="data">
194 <th id
="th<?php echo ++$i; ?>"></th
>
195 <th id
="th<?php echo ++$i; ?>">#</th>
196 <th id
="th<?php echo ++$i; ?>" class="column"><?php
echo __('Column'); ?
></th
>
197 <th id
="th<?php echo ++$i; ?>" class="type"><?php
echo __('Type'); ?
></th
>
198 <th id
="th<?php echo ++$i; ?>" class="collation"><?php
echo __('Collation'); ?
></th
>
199 <th id
="th<?php echo ++$i; ?>" class="attributes"><?php
echo __('Attributes'); ?
></th
>
200 <th id
="th<?php echo ++$i; ?>" class="null"><?php
echo __('Null'); ?
></th
>
201 <th id
="th<?php echo ++$i; ?>" class="default"><?php
echo __('Default'); ?
></th
>
202 <th id
="th<?php echo ++$i; ?>" class="extra"><?php
echo __('Extra'); ?
></th
>
203 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
204 <th id
="th<?php echo ++$i; ?>" class="view"><?php
echo __('View'); ?
></th
>
206 <th colspan
="7" id
="th<?php echo ++$i; ?>" class="action"><?php
echo __('Action'); ?
></th
>
218 $comments_map = array();
221 if ($GLOBALS['cfg']['ShowPropertyComments']) {
222 require_once './libraries/transformations.lib.php';
224 //$cfgRelation = PMA_getRelationsParam();
226 $comments_map = PMA_getComments($db, $table);
228 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
229 $mime_map = PMA_getMIME($db, $table, true);
234 $aryFields = array();
235 $checked = (!empty($checkall) ?
' checked="checked"' : '');
238 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
241 $aryFields[] = $row['Field'];
243 $type = $row['Type'];
244 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
246 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
247 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
249 // for the case ENUM('–','“')
250 $type = htmlspecialchars($type);
251 if(strlen($type) > $GLOBALS['cfg']['LimitChars']) {
252 $type = '<abbr title="full text">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
261 $type_nowrap = ' nowrap="nowrap"';
262 // strip the "BINARY" attribute, except if we find "BINARY(" because
263 // this would be a BINARY or VARBINARY field type
264 if (!preg_match('@BINARY[\(]@i', $type)) {
265 $type = preg_replace('@BINARY@i', '', $type);
267 $type = preg_replace('@ZEROFILL@i', '', $type);
268 $type = preg_replace('@UNSIGNED@i', '', $type);
273 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
274 $binary = stristr($row['Type'], 'blob') ||
stristr($row['Type'], 'binary');
279 $unsigned = stristr($row['Type'], 'unsigned');
280 $zerofill = stristr($row['Type'], 'zerofill');
283 unset($field_charset);
284 if ((substr($type, 0, 4) == 'char'
285 ||
substr($type, 0, 7) == 'varchar'
286 ||
substr($type, 0, 4) == 'text'
287 ||
substr($type, 0, 8) == 'tinytext'
288 ||
substr($type, 0, 10) == 'mediumtext'
289 ||
substr($type, 0, 8) == 'longtext'
290 ||
substr($type, 0, 3) == 'set'
291 ||
substr($type, 0, 4) == 'enum'
293 if (strpos($type, ' character set ')) {
294 $type = substr($type, 0, strpos($type, ' character set '));
296 if (!empty($row['Collation'])) {
297 $field_charset = $row['Collation'];
305 // Display basic mimetype [MIME]
306 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
307 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
314 $attribute = 'BINARY';
317 $attribute = 'UNSIGNED';
320 $attribute = 'UNSIGNED ZEROFILL';
323 // MySQL 4.1.2+ TIMESTAMP options
324 // (if on_update_current_timestamp is set, then it's TRUE)
325 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
326 $attribute = 'on update CURRENT_TIMESTAMP';
329 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
330 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
332 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']) {
337 if (!isset($row['Default'])) {
338 if ($row['Null'] == 'YES') {
339 $row['Default'] = '<i>NULL</i>';
342 $row['Default'] = htmlspecialchars($row['Default']);
345 $field_encoded = urlencode($row['Field']);
346 $field_name = htmlspecialchars($row['Field']);
347 $displayed_field_name = $field_name;
349 // underline commented fields and display a hover-title (CSS only)
351 if (isset($comments_map[$row['Field']])) {
352 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
355 if ($primary && $primary->hasColumn($field_name)) {
356 $displayed_field_name = '<u>' . $field_name . '</u>';
360 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
362 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo htmlspecialchars($row['Field']); ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
365 <?php
echo $rownum; ?
>
367 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $displayed_field_name; ?
></label
></th
>
368 <td
<?php
echo $type_nowrap; ?
>><bdo dir
="ltr" xml
:lang
="en"><?php
echo $type; echo $type_mime; ?
></bdo
></td
>
369 <td
><?php
echo (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?
></td
>
370 <td nowrap
="nowrap" class="column_attribute"><?php
echo $attribute; ?
></td
>
371 <td
><?php
echo (($row['Null'] == 'YES') ?
__('Yes') : __('No')); ?
></td
>
372 <td nowrap
="nowrap"><?php
373 if (isset($row['Default'])) {
374 if ($extracted_fieldspec['type'] == 'bit') {
375 // here, $row['Default'] contains something like b'010'
376 echo PMA_convert_bit_default_value($row['Default']);
378 echo $row['Default'];
382 echo '<i>' . _pgettext('None for default','None') . '</i>';
384 <td nowrap
="nowrap"><?php
echo strtoupper($row['Extra']); ?
></td
>
385 <td align
="center" class="browse">
386 <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'])); ?>">
387 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
389 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
390 <td align
="center" class="edit">
391 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
392 <?php
echo $titles['Change']; ?
></a
>
394 <td align
="center" class="drop">
395 <a 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']); ?>&zero_rows=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>"
396 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
397 <?php
echo $titles['Drop']; ?
></a
>
399 <td align
="center" class="primary">
401 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
($primary && $primary->hasColumn($field_name))) {
402 echo $titles['NoPrimary'] . "\n";
403 $primary_enabled = false;
407 <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']))); ?>"
408 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($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']) . ')'); ?>&zero_rows=<?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']) . ')'); ?>&zero_rows=<?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']) . ')'); ?>&zero_rows=<?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']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>"
484 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
485 <?php
echo $hidden_titles['Primary']; ?
>
489 echo $hidden_titles['NoPrimary'];
493 <div
class="action_unique">
495 if(isset($unique_enabled)) {
496 if($unique_enabled) { ?
>
497 <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']))); ?>">
498 <?php
echo $hidden_titles['Unique']; ?
>
502 echo $hidden_titles['NoUnique'];
506 <div
class="action_index">
508 if(isset($index_enabled)) {
509 if($index_enabled) { ?
>
510 <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']))); ?>">
511 <?php
echo $hidden_titles['Index']; ?
>
515 echo $hidden_titles['NoIndex'];
519 <div
class="action_fulltext">
521 if(isset($fulltext_enabled)) {
522 if($fulltext_enabled) { ?
>
523 <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']))); ?>">
524 <?php
echo $hidden_titles['IdxFulltext']; ?
>
528 echo $hidden_titles['NoIdxFulltext'];
536 unset($field_charset);
539 echo '</tbody>' . "\n"
542 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
545 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
546 width
="38" height
="22" alt
="<?php echo __('With selected:'); ?>" />
547 <a href
="<?php echo $checkall_url; ?>&checkall=1"
548 onclick
="if (markAllRows('fieldsForm')) return false;">
549 <?php
echo __('Check All'); ?
></a
>
551 <a href
="<?php echo $checkall_url; ?>"
552 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
553 <?php
echo __('Uncheck All'); ?
></a
>
555 <i
><?php
echo __('With selected:'); ?
></i
>
558 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png');
560 if (! $tbl_is_view && ! $db_is_information_schema) {
561 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png');
562 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png');
563 if ('ARCHIVE' != $tbl_type) {
564 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png');
565 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png');
566 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png');
568 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA')) {
569 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png');
581 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
582 if ($cfg['PropertiesIconic']) {
583 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
585 echo __('Print view');
589 if (! $tbl_is_view && ! $db_is_information_schema) {
591 // if internal relations are available, or foreign keys are supported
592 // ($tbl_type comes from libraries/tbl_info.inc.php)
593 if ($cfgRelation['relwork'] ||
PMA_foreignkey_supported($tbl_type)) {
595 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
596 if ($cfg['PropertiesIconic']) {
597 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
599 echo __('Relation view');
604 <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
605 if ($cfg['PropertiesIconic']) {
606 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
608 echo __('Propose table structure');
610 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
613 if(PMA_Tracker
::isActive())
615 echo '<a href="tbl_tracking.php?' . $url_query . '">';
617 if ($cfg['PropertiesIconic'])
619 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
621 echo __('Track table') . '</a>';
626 <form method
="post" action
="tbl_addfield.php"
627 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
629 echo PMA_generate_common_hidden_inputs($db, $table);
630 if ($cfg['PropertiesIconic']) {
631 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
633 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
635 // I tried displaying the drop-down inside the label but with Firefox
636 // the drop-down was blinking
637 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
638 foreach ($aryFields as $fieldname) {
639 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
642 $fieldOptions .= '</select>';
645 'last' => __('At End of Table'),
646 'first' => __('At Beginning of Table'),
647 'after' => sprintf(__('After %s'), '')
649 PMA_display_html_radio('field_where', $choices, 'last', false);
651 unset($fieldOptions, $choices);
653 <input type
="submit" value
="<?php echo __('Go'); ?>" />
655 <iframe
class="IE_hack" scrolling
="no"></iframe
>
661 * If there are more than 20 rows, displays browse/select/insert/empty/drop
664 if ($fields_cnt > 20) {
665 require './libraries/tbl_links.inc.php';
666 } // end if ($fields_cnt > 20)
672 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
676 echo PMA_Index
::getView($table, $db);
679 <form action
="./tbl_indexes.php" method
="post"
680 onsubmit
="return checkFormElementInRange(this, 'idx_num_fields',
681 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
685 echo PMA_generate_common_hidden_inputs($db, $table);
686 echo sprintf(__('Create an index on %s columns'),
687 '<input type="text" size="2" name="added_fields" value="1" />');
689 <input type
="submit" name
="create_index" value
="<?php echo __('Go'); ?>"
690 onclick
="return checkFormElementInRange(this.form,
692 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
700 PMA_generate_slider_effect('tablestatistics', __('Details...'));
703 * Displays Space usage and row statistics
705 // BEGIN - Calc Table Space
706 // Get valid statistics whatever is the table type
707 if ($cfg['ShowStats']) {
708 if (empty($showtable)) {
709 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
713 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
714 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
720 $mergetable = PMA_Table
::isMerge($GLOBALS['db'], $GLOBALS['table']);
722 // this is to display for example 261.2 MiB instead of 268k KiB
725 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
726 if ($mergetable == false) {
727 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
729 // InnoDB returns a huge value in Data_free, do not use it
730 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
731 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
732 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
734 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
736 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
737 if ($table_info_num_rows > 0) {
738 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
745 <a name
="showusage"></a
>
746 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
747 <table id
="tablespaceusage" class="data">
748 <caption
class="tblHeaders"><?php
echo __('Space usage'); ?
></caption
>
751 <th
><?php
echo __('Type'); ?
></th
>
752 <th colspan
="2"><?php
echo __('Usage'); ?
></th
>
756 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
757 <th
class="name"><?php
echo __('Data'); ?
></th
>
758 <td
class="value"><?php
echo $data_size; ?
></td
>
759 <td
class="unit"><?php
echo $data_unit; ?
></td
>
762 if (isset($index_size)) {
764 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
765 <th
class="name"><?php
echo __('Index'); ?
></th
>
766 <td
class="value"><?php
echo $index_size; ?
></td
>
767 <td
class="unit"><?php
echo $index_unit; ?
></td
>
771 if (isset($free_size)) {
773 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
774 <th
class="name"><?php
echo __('Overhead'); ?
></th
>
775 <td
class="value"><?php
echo $free_size; ?
></td
>
776 <td
class="unit"><?php
echo $free_unit; ?
></td
>
778 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
779 <th
class="name"><?php
echo __('Effective'); ?
></th
>
780 <td
class="value"><?php
echo $effect_size; ?
></td
>
781 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
785 if (isset($tot_size) && $mergetable == false) {
787 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
788 <th
class="name"><?php
echo __('Total'); ?
></th
>
789 <td
class="value"><?php
echo $tot_size; ?
></td
>
790 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
794 // Optimize link if overhead
795 if (isset($free_size) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'MARIA' ||
$tbl_type == 'BDB')) {
797 <tr
class="tblFooters">
798 <td colspan
="3" align
="center">
799 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
800 if ($cfg['PropertiesIconic']) {
801 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
803 echo __('Optimize table');
816 <table id
="tablerowstats" class="data">
817 <caption
class="tblHeaders"><?php
echo __('Row Statistics'); ?
></caption
>
820 <th
><?php
echo __('Statements'); ?
></th
>
821 <th
><?php
echo __('Value'); ?
></th
>
826 if (isset($showtable['Row_format'])) {
828 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
829 <th
class="name"><?php
echo __('Format'); ?
></th
>
830 <td
class="value"><?php
831 if ($showtable['Row_format'] == 'Fixed') {
833 } elseif ($showtable['Row_format'] == 'Dynamic') {
836 echo $showtable['Row_format'];
842 if (! empty($showtable['Create_options'])) {
844 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
845 <th
class="name"><?php
echo __('Options'); ?
></th
>
846 <td
class="value"><?php
847 if ($showtable['Create_options'] == 'partitioned') {
848 echo __('partitioned');
850 echo $showtable['Create_options'];
856 if (!empty($tbl_collation)) {
858 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
859 <th
class="name"><?php
echo __('Collation'); ?
></th
>
860 <td
class="value"><?php
861 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
866 if (!$is_innodb && isset($showtable['Rows'])) {
868 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
869 <th
class="name"><?php
echo __('Rows'); ?
></th
>
870 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
874 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
876 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
877 <th
class="name"><?php
echo __('Row length'); ?
> ø
;</th
>
878 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
882 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
884 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
885 <th
class="name"><?php
echo __(' Row size '); ?
> ø
;</th
>
886 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
890 if (isset($showtable['Auto_increment'])) {
892 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
893 <th
class="name"><?php
echo __('Next'); ?
> Autoindex
</th
>
894 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
898 if (isset($showtable['Create_time'])) {
900 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
901 <th
class="name"><?php
echo __('Creation'); ?
></th
>
902 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
906 if (isset($showtable['Update_time'])) {
908 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
909 <th
class="name"><?php
echo __('Last update'); ?
></th
>
910 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
914 if (isset($showtable['Check_time'])) {
916 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
917 <th
class="name"><?php
echo __('Last check'); ?
></th
>
918 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
926 <!-- close slider div
-->
931 // END - Calc Table Space
933 require './libraries/tbl_triggers.lib.php';
935 echo '<div class="clearfloat"></div>' . "\n";
938 * Displays the footer
940 require './libraries/footer.inc.php';