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 = 'ftext';
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_DRIZZLE
125 ?
PMA_DBI_query('SHOW COLUMNS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
)
126 : PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
127 $fields_cnt = PMA_DBI_num_rows($fields_rs);
129 // Get more complete field information
130 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
131 // but later, if the analyser returns more information, it
132 // could be executed for any MySQL version and replace
133 // the info given by SHOW FULL FIELDS FROM.
135 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
136 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
137 // and SHOW CREATE TABLE says NOT NULL (tested
138 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
140 $show_create_table = PMA_DBI_fetch_value(
141 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
143 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
146 * prepare table infos
148 // action titles (image or string)
150 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
151 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
152 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
153 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
154 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
155 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
156 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
157 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
158 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
159 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
160 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
161 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
163 // hidden action titles (image and string)
164 $hidden_titles = array();
165 $hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), false, true);
166 $hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Add primary key'), false, true);
167 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Add primary key'), false, true);
168 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Add index'), false, true);
169 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Add index'), false, true);
170 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Add unique index'), false, true);
171 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Add unique index'), false, true);
172 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Add FULLTEXT index'), false, true);
173 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Add FULLTEXT index'), false, true);
176 * Displays the table structure ('show table' works correct since 3.23.03)
178 /* TABLE INFORMATION */
182 <form method
="post" action
="tbl_structure.php" name
="fieldsForm" id
="fieldsForm">
183 <?php
echo PMA_generate_common_hidden_inputs($db, $table);
184 echo '<input type="hidden" name="table_type" value=';
185 if($db_is_information_schema) {
186 echo '"information_schema" />';
187 } else if ($tbl_is_view) {
193 <table id
="tablestructure" class="data">
196 <th id
="th<?php echo ++$i; ?>"></th
>
197 <th id
="th<?php echo ++$i; ?>">#</th>
198 <th id
="th<?php echo ++$i; ?>" class="column"><?php
echo __('Name'); ?
></th
>
199 <th id
="th<?php echo ++$i; ?>" class="type"><?php
echo __('Type'); ?
></th
>
200 <th id
="th<?php echo ++$i; ?>" class="collation"><?php
echo __('Collation'); ?
></th
>
201 <th id
="th<?php echo ++$i; ?>" class="attributes"><?php
echo __('Attributes'); ?
></th
>
202 <th id
="th<?php echo ++$i; ?>" class="null"><?php
echo __('Null'); ?
></th
>
203 <th id
="th<?php echo ++$i; ?>" class="default"><?php
echo __('Default'); ?
></th
>
204 <th id
="th<?php echo ++$i; ?>" class="extra"><?php
echo __('Extra'); ?
></th
>
205 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
206 <th id
="th<?php echo ++$i; ?>" class="view"><?php
echo __('View'); ?
></th
>
208 <th colspan
="7" id
="th<?php echo ++$i; ?>" class="action"><?php
echo __('Action'); ?
></th
>
220 $comments_map = array();
223 if ($GLOBALS['cfg']['ShowPropertyComments']) {
224 require_once './libraries/transformations.lib.php';
226 //$cfgRelation = PMA_getRelationsParam();
228 $comments_map = PMA_getComments($db, $table);
230 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
231 $mime_map = PMA_getMIME($db, $table, true);
236 $aryFields = array();
237 $checked = (!empty($checkall) ?
' checked="checked"' : '');
240 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
243 $aryFields[] = $row['Field'];
245 $type = $row['Type'];
246 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
248 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
249 $type = $extracted_fieldspec['type'] . '(' .
250 str_replace("','", "', '", $extracted_fieldspec['spec_in_brackets']) . ')';
252 // for the case ENUM('–','“')
253 $type = htmlspecialchars($type);
254 if(strlen($type) > $GLOBALS['cfg']['LimitChars']) {
255 $type = '<abbr title="full text">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
264 $type_nowrap = ' nowrap="nowrap"';
265 // strip the "BINARY" attribute, except if we find "BINARY(" because
266 // this would be a BINARY or VARBINARY field type
267 if (!preg_match('@BINARY[\(]@i', $type)) {
268 $type = preg_replace('@BINARY@i', '', $type);
270 $type = preg_replace('@ZEROFILL@i', '', $type);
271 $type = preg_replace('@UNSIGNED@i', '', $type);
276 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
277 $binary = stristr($row['Type'], 'blob') ||
stristr($row['Type'], 'binary');
282 $unsigned = stristr($row['Type'], 'unsigned');
283 $zerofill = stristr($row['Type'], 'zerofill');
286 unset($field_charset);
287 if ((substr($type, 0, 4) == 'char'
288 ||
substr($type, 0, 7) == 'varchar'
289 ||
substr($type, 0, 4) == 'text'
290 ||
substr($type, 0, 8) == 'tinytext'
291 ||
substr($type, 0, 10) == 'mediumtext'
292 ||
substr($type, 0, 8) == 'longtext'
293 ||
substr($type, 0, 3) == 'set'
294 ||
substr($type, 0, 4) == 'enum'
296 if (strpos($type, ' character set ')) {
297 $type = substr($type, 0, strpos($type, ' character set '));
299 if (!empty($row['Collation'])) {
300 $field_charset = $row['Collation'];
308 // Display basic mimetype [MIME]
309 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
310 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
317 $attribute = 'BINARY';
320 $attribute = 'UNSIGNED';
323 $attribute = 'UNSIGNED ZEROFILL';
326 // MySQL 4.1.2+ TIMESTAMP options
327 // (if on_update_current_timestamp is set, then it's TRUE)
328 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
329 $attribute = 'on update CURRENT_TIMESTAMP';
332 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
333 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
335 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']) {
340 if (! isset($row['Default'])) {
341 if ($row['Null'] == 'YES') {
342 $row['Default'] = '<i>NULL</i>';
345 $row['Default'] = htmlspecialchars($row['Default']);
348 $field_encoded = urlencode($row['Field']);
349 $field_name = htmlspecialchars($row['Field']);
350 $displayed_field_name = $field_name;
352 // underline commented fields and display a hover-title (CSS only)
354 if (isset($comments_map[$row['Field']])) {
355 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
358 if ($primary && $primary->hasColumn($field_name)) {
359 $displayed_field_name = '<u>' . $field_name . '</u>';
363 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
365 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo htmlspecialchars($row['Field']); ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
368 <?php
echo $rownum; ?
>
370 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $displayed_field_name; ?
></label
></th
>
371 <td
<?php
echo $type_nowrap; ?
>><bdo dir
="ltr" xml
:lang
="en"><?php
echo $type; echo $type_mime; ?
></bdo
></td
>
372 <td
><?php
echo (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?
></td
>
373 <td nowrap
="nowrap" class="column_attribute"><?php
echo $attribute; ?
></td
>
374 <td
><?php
echo (($row['Null'] == 'YES') ?
__('Yes') : __('No')); ?
></td
>
375 <td nowrap
="nowrap"><?php
376 if (isset($row['Default'])) {
377 if ($extracted_fieldspec['type'] == 'bit') {
378 // here, $row['Default'] contains something like b'010'
379 echo PMA_convert_bit_default_value($row['Default']);
381 echo $row['Default'];
385 echo '<i>' . _pgettext('None for default','None') . '</i>';
387 <td nowrap
="nowrap"><?php
echo strtoupper($row['Extra']); ?
></td
>
388 <td align
="center" class="browse">
389 <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'])); ?>">
390 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
392 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
393 <td align
="center" class="edit">
394 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
395 <?php
echo $titles['Change']; ?
></a
>
397 <td align
="center" class="drop">
398 <a
<?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' 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']))); ?>" >
399 <?php
echo $titles['Drop']; ?
></a
>
401 <td align
="center" class="primary">
403 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
($primary && $primary->hasColumn($field_name))) {
404 echo $titles['NoPrimary'] . "\n";
405 $primary_enabled = false;
409 <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']))); ?>" >
410 <?php
echo $titles['Primary']; ?
></a
>
411 <?php
$primary_enabled = true;
416 <td align
="center" class="unique">
418 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
isset($columns_with_unique_index[$field_name])) {
419 echo $titles['NoUnique'] . "\n";
420 $unique_enabled = false;
424 <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']))); ?>">
425 <?php
echo $titles['Unique']; ?
></a
>
426 <?php
$unique_enabled = true;
431 <td align
="center" class="index">
433 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type) {
434 echo $titles['NoIndex'] . "\n";
435 $index_enabled = false;
439 <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']))); ?>">
440 <?php
echo $titles['Index']; ?
></a
>
442 $index_enabled = true;
448 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'ARIA' ||
$tbl_type == 'MARIA')
449 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
450 && (strpos(' ' . $type, 'text') ||
strpos(' ' . $type, 'char'))) {
453 <td align
="center" nowrap
="nowrap" class="fulltext">
454 <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']))); ?>">
455 <?php
echo $titles['IdxFulltext']; ?
></a
>
456 <?php
$fulltext_enabled = true; ?
>
462 <td align
="center" nowrap
="nowrap" class="fulltext">
463 <?php
echo $titles['NoIdxFulltext'] . "\n"; ?
>
464 <?php
$fulltext_enabled = false; ?
>
467 } // end if... else...
470 <td
class="more_opts" id
="more_opts<?php echo $rownum; ?>">
471 <?php
echo __('More'); ?
> <img src
="<?php echo $pmaThemeImage . 'more.png'; ?>" alt
="<?php echo __('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
<?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' 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'];
534 } // end if (! $tbl_is_view && ! $db_is_information_schema)
538 unset($field_charset);
541 echo '</tbody>' . "\n"
544 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
547 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
548 width
="38" height
="22" alt
="<?php echo __('With selected:'); ?>" />
549 <a href
="<?php echo $checkall_url; ?>&checkall=1"
550 onclick
="if (markAllRows('fieldsForm')) return false;">
551 <?php
echo __('Check All'); ?
></a
>
553 <a href
="<?php echo $checkall_url; ?>"
554 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
555 <?php
echo __('Uncheck All'); ?
></a
>
557 <i
><?php
echo __('With selected:'); ?
></i
>
560 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png', 'browse');
562 if (! $tbl_is_view && ! $db_is_information_schema) {
563 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png', 'change');
564 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png', 'drop');
565 if ('ARCHIVE' != $tbl_type) {
566 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png', 'primary');
567 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png', 'unique');
568 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png', 'index');
571 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'ARIA' ||
$tbl_type == 'MARIA')) {
572 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png', 'ftext');
584 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
585 if ($cfg['PropertiesIconic']) {
586 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
588 echo __('Print view');
592 if (! $tbl_is_view && ! $db_is_information_schema) {
594 // if internal relations are available, or foreign keys are supported
595 // ($tbl_type comes from libraries/tbl_info.inc.php)
596 if ($cfgRelation['relwork'] ||
PMA_foreignkey_supported($tbl_type)) {
598 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
599 if ($cfg['PropertiesIconic']) {
600 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
602 echo __('Relation view');
607 <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
608 if ($cfg['PropertiesIconic']) {
609 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
611 echo __('Propose table structure');
613 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
616 if(PMA_Tracker
::isActive())
618 echo '<a href="tbl_tracking.php?' . $url_query . '">';
620 if ($cfg['PropertiesIconic'])
622 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
624 echo __('Track table') . '</a>';
629 <form method
="post" action
="tbl_addfield.php"
630 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
632 echo PMA_generate_common_hidden_inputs($db, $table);
633 if ($cfg['PropertiesIconic']) {
634 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
636 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
638 // I tried displaying the drop-down inside the label but with Firefox
639 // the drop-down was blinking
640 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
641 foreach ($aryFields as $fieldname) {
642 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
645 $fieldOptions .= '</select>';
648 'last' => __('At End of Table'),
649 'first' => __('At Beginning of Table'),
650 'after' => sprintf(__('After %s'), '')
652 PMA_display_html_radio('field_where', $choices, 'last', false);
654 unset($fieldOptions, $choices);
656 <input type
="submit" value
="<?php echo __('Go'); ?>" />
658 <iframe
class="IE_hack" scrolling
="no"></iframe
>
664 * If there are more than 20 rows, displays browse/select/insert/empty/drop
667 if ($fields_cnt > 20) {
668 require './libraries/tbl_links.inc.php';
669 } // end if ($fields_cnt > 20)
675 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
679 echo PMA_Index
::getView($table, $db);
682 <form action
="./tbl_indexes.php" method
="post"
683 onsubmit
="return checkFormElementInRange(this, 'idx_num_fields',
684 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
688 echo PMA_generate_common_hidden_inputs($db, $table);
689 echo sprintf(__('Create an index on %s columns'),
690 '<input type="text" size="2" name="added_fields" value="1" />');
692 <input type
="submit" name
="create_index" value
="<?php echo __('Go'); ?>"
693 onclick
="return checkFormElementInRange(this.form,
695 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
704 * Displays Space usage and row statistics
706 // BEGIN - Calc Table Space
707 // Get valid statistics whatever is the table type
708 if ($cfg['ShowStats']) {
709 echo '<div id="tablestatistics">';
710 if (empty($showtable)) {
711 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
715 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
716 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
722 $mergetable = PMA_Table
::isMerge($GLOBALS['db'], $GLOBALS['table']);
724 // this is to display for example 261.2 MiB instead of 268k KiB
727 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
728 if ($mergetable == false) {
729 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
731 // InnoDB returns a huge value in Data_free, do not use it
732 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
733 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
734 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
736 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
738 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
739 if ($table_info_num_rows > 0) {
740 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
747 <a name
="showusage"></a
>
748 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
749 <table id
="tablespaceusage" class="data">
750 <caption
class="tblHeaders"><?php
echo __('Space usage'); ?
></caption
>
753 <th
><?php
echo __('Type'); ?
></th
>
754 <th colspan
="2"><?php
echo __('Usage'); ?
></th
>
758 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
759 <th
class="name"><?php
echo __('Data'); ?
></th
>
760 <td
class="value"><?php
echo $data_size; ?
></td
>
761 <td
class="unit"><?php
echo $data_unit; ?
></td
>
764 if (isset($index_size)) {
766 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
767 <th
class="name"><?php
echo __('Index'); ?
></th
>
768 <td
class="value"><?php
echo $index_size; ?
></td
>
769 <td
class="unit"><?php
echo $index_unit; ?
></td
>
773 if (isset($free_size)) {
775 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> error">
776 <th
class="name"><?php
echo __('Overhead'); ?
></th
>
777 <td
class="value"><?php
echo $free_size; ?
></td
>
778 <td
class="unit"><?php
echo $free_unit; ?
></td
>
780 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
781 <th
class="name"><?php
echo __('Effective'); ?
></th
>
782 <td
class="value"><?php
echo $effect_size; ?
></td
>
783 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
787 if (isset($tot_size) && $mergetable == false) {
789 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
790 <th
class="name"><?php
echo __('Total'); ?
></th
>
791 <td
class="value"><?php
echo $tot_size; ?
></td
>
792 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
796 // Optimize link if overhead
797 if (isset($free_size) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'ARIA' ||
$tbl_type == 'MARIA' ||
$tbl_type == 'BDB')) {
799 <tr
class="tblFooters">
800 <td colspan
="3" align
="center">
801 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
802 if ($cfg['PropertiesIconic']) {
803 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
805 echo __('Optimize table');
818 <table id
="tablerowstats" class="data">
819 <caption
class="tblHeaders"><?php
echo __('Row Statistics'); ?
></caption
>
822 <th
><?php
echo __('Statements'); ?
></th
>
823 <th
><?php
echo __('Value'); ?
></th
>
828 if (isset($showtable['Row_format'])) {
830 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
831 <th
class="name"><?php
echo __('Format'); ?
></th
>
832 <td
class="value"><?php
833 if ($showtable['Row_format'] == 'Fixed') {
835 } elseif ($showtable['Row_format'] == 'Dynamic') {
838 echo $showtable['Row_format'];
844 if (! empty($showtable['Create_options'])) {
846 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
847 <th
class="name"><?php
echo __('Options'); ?
></th
>
848 <td
class="value"><?php
849 if ($showtable['Create_options'] == 'partitioned') {
850 echo __('partitioned');
852 echo $showtable['Create_options'];
858 if (!empty($tbl_collation)) {
860 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
861 <th
class="name"><?php
echo __('Collation'); ?
></th
>
862 <td
class="value"><?php
863 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
868 if (!$is_innodb && isset($showtable['Rows'])) {
870 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
871 <th
class="name"><?php
echo __('Rows'); ?
></th
>
872 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
876 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
878 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
879 <th
class="name"><?php
echo __('Row length'); ?
> ø
;</th
>
880 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
884 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
886 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
887 <th
class="name"><?php
echo __(' Row size '); ?
> ø
;</th
>
888 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
892 if (isset($showtable['Auto_increment'])) {
894 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
895 <th
class="name"><?php
echo __('Next'); ?
> Autoindex
</th
>
896 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
900 if (isset($showtable['Create_time'])) {
902 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
903 <th
class="name"><?php
echo __('Creation'); ?
></th
>
904 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
908 if (isset($showtable['Update_time'])) {
910 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
911 <th
class="name"><?php
echo __('Last update'); ?
></th
>
912 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
916 if (isset($showtable['Check_time'])) {
918 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
919 <th
class="name"><?php
echo __('Last check'); ?
></th
>
920 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
928 <!-- close tablestatistics div
-->
933 // END - Calc Table Space
935 require './libraries/tbl_triggers.inc.php';
937 echo '<div class="clearfloat"></div>' . "\n";
940 * Displays the footer
942 require './libraries/footer.inc.php';