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.16.custom.js';
16 $GLOBALS['js_include'][] = 'tbl_structure.js';
17 $GLOBALS['js_include'][] = 'indexes.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_spatial_x'])) {
34 $submit_mult = 'spatial';
35 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
36 $submit_mult = 'ftext';
37 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
38 $submit_mult = 'browse';
39 } elseif (isset($_REQUEST['submit_mult'])) {
40 $submit_mult = $_REQUEST['submit_mult'];
41 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) {
42 $submit_mult = 'row_delete';
43 if (isset($_REQUEST['selected'])) {
44 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
48 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
49 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
50 if ($submit_mult == 'browse') {
51 // browsing the table displaying only selected fields/columns
52 $GLOBALS['active_page'] = 'sql.php';
54 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
55 if ($sql_query == '') {
56 $sql_query .= 'SELECT ' . PMA_backquote($sval);
58 $sql_query .= ', ' . PMA_backquote($sval);
62 // what is this htmlspecialchars() for??
63 //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
64 $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
68 // handle multiple field commands
69 // handle confirmation of deleting multiple fields/columns
70 $action = 'tbl_structure.php';
71 include './libraries/mult_submits.inc.php';
72 //require_once './libraries/header.inc.php';
73 //require_once './libraries/tbl_links.inc.php';
75 if (empty($message)) {
76 $message = PMA_Message
::success();
82 * Gets the relation settings
84 $cfgRelation = PMA_getRelationsParam();
89 require_once './libraries/tbl_common.php';
90 $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php';
91 $url_params['goto'] = 'tbl_structure.php';
92 $url_params['back'] = 'tbl_structure.php';
95 * Prepares the table structure display
100 * Gets tables informations
102 require_once './libraries/tbl_info.inc.php';
105 * Displays top menu links
107 require_once './libraries/tbl_links.inc.php';
108 require_once './libraries/Index.class.php';
110 // 2. Gets table keys and retains them
111 // @todo should be: $server->db($db)->table($table)->primary()
112 $primary = PMA_Index
::getPrimary($table, $db);
114 $columns_with_unique_index = array();
115 foreach (PMA_Index
::getFromTable($table, $db) as $index) {
116 if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
117 $columns = $index->getColumns();
118 foreach ($columns as $column_name => $dummy) {
119 $columns_with_unique_index[$column_name] = 1;
123 unset($index, $columns, $column_name, $dummy);
126 $fields = (array) PMA_DBI_get_columns($db, $table, null, true);
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 COLUMNS FROM.
134 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
135 // SHOW FULL COLUMNS 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'));
150 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'));
151 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'));
152 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'));
153 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'));
154 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'));
155 $titles['Spatial'] = PMA_getIcon('b_spatial.png', __('Spatial'));
156 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'));
157 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'));
158 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'));
159 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'));
160 $titles['NoSpatial'] = PMA_getIcon('bd_spatial.png', __('Spatial'));
161 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'));
162 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'));
164 // hidden action titles (image and string)
165 $hidden_titles = array();
166 $hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
167 $hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Add primary key'), true);
168 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Add primary key'), true);
169 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Add index'), true);
170 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Add index'), true);
171 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Add unique index'), true);
172 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Add unique index'), true);
173 $hidden_titles['Spatial'] = PMA_getIcon('b_spatial.png', __('Add SPATIAL index'), true);
174 $hidden_titles['NoSpatial'] = PMA_getIcon('bd_spatial.png', __('Add SPATIAL index'), true);
175 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Add FULLTEXT index'), true);
176 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Add FULLTEXT index'), true);
179 * Displays the table structure ('show table' works correct since 3.23.03)
181 /* TABLE INFORMATION */
185 <form method
="post" action
="tbl_structure.php" name
="fieldsForm" id
="fieldsForm" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>>
186 <?php
echo PMA_generate_common_hidden_inputs($db, $table);
187 echo '<input type="hidden" name="table_type" value=';
188 if ($db_is_information_schema) {
189 echo '"information_schema" />';
190 } else if ($tbl_is_view) {
196 <table id
="tablestructure" class="data<?php
197 if ($GLOBALS['cfg']['PropertiesIconic'] === true) echo ' PropertiesIconic'; ?>">
200 <th id
="th<?php echo ++$i; ?>"></th
>
201 <th id
="th<?php echo ++$i; ?>">#</th>
202 <th id
="th<?php echo ++$i; ?>" class="column"><?php
echo __('Name'); ?
></th
>
203 <th id
="th<?php echo ++$i; ?>" class="type"><?php
echo __('Type'); ?
></th
>
204 <th id
="th<?php echo ++$i; ?>" class="collation"><?php
echo __('Collation'); ?
></th
>
205 <th id
="th<?php echo ++$i; ?>" class="attributes"><?php
echo __('Attributes'); ?
></th
>
206 <th id
="th<?php echo ++$i; ?>" class="null"><?php
echo __('Null'); ?
></th
>
207 <th id
="th<?php echo ++$i; ?>" class="default"><?php
echo __('Default'); ?
></th
>
208 <th id
="th<?php echo ++$i; ?>" class="extra"><?php
echo __('Extra'); ?
></th
>
209 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
210 <th id
="th<?php echo ++$i; ?>" class="view"><?php
echo __('View'); ?
></th
>
217 if ($GLOBALS['cfg']['PropertiesIconic']) {
221 id
="th<?php echo ++$i; ?>" class="action"><?php
echo __('Action'); ?
></th
>
233 $comments_map = array();
236 if ($GLOBALS['cfg']['ShowPropertyComments']) {
237 include_once './libraries/transformations.lib.php';
239 //$cfgRelation = PMA_getRelationsParam();
241 $comments_map = PMA_getComments($db, $table);
243 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
244 $mime_map = PMA_getMIME($db, $table, true);
249 $aryFields = array();
250 $checked = (!empty($checkall) ?
' checked="checked"' : '');
253 foreach ($fields as $row) {
256 $aryFields[] = $row['Field'];
258 $type = $row['Type'];
259 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
261 if ('set' == $extracted_fieldspec['type'] ||
'enum' == $extracted_fieldspec['type']) {
264 $type_nowrap = ' nowrap="nowrap"';
266 $type = $extracted_fieldspec['print_type'];
270 // for the case ENUM('–','“')
271 $type = htmlspecialchars($type);
272 // in case it is too long
274 if (strlen($type) > $GLOBALS['cfg']['LimitChars']) {
276 $type = '<abbr title="' . $type . '">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
279 unset($field_charset);
280 if ((substr($type, $start, 4) == 'char'
281 ||
substr($type, $start, 7) == 'varchar'
282 ||
substr($type, $start, 4) == 'text'
283 ||
substr($type, $start, 8) == 'tinytext'
284 ||
substr($type, $start, 10) == 'mediumtext'
285 ||
substr($type, $start, 8) == 'longtext'
286 ||
substr($type, $start, 3) == 'set'
287 ||
substr($type, $start, 4) == 'enum')
288 && !$extracted_fieldspec['binary']
290 if (strpos($type, ' character set ')) {
291 $type = substr($type, 0, strpos($type, ' character set '));
293 if (!empty($row['Collation'])) {
294 $field_charset = $row['Collation'];
302 // Display basic mimetype [MIME]
303 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
304 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
309 $attribute = $extracted_fieldspec['attribute'];
311 // MySQL 4.1.2+ TIMESTAMP options
312 // (if on_update_current_timestamp is set, then it's TRUE)
313 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
314 $attribute = 'on update CURRENT_TIMESTAMP';
317 // here, we have a TIMESTAMP that SHOW FULL COLUMNS reports as having the
318 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
320 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']) {
325 if (! isset($row['Default'])) {
326 if ($row['Null'] == 'YES') {
327 $row['Default'] = '<i>NULL</i>';
330 $row['Default'] = htmlspecialchars($row['Default']);
333 $field_encoded = urlencode($row['Field']);
334 $field_name = htmlspecialchars($row['Field']);
335 $displayed_field_name = $field_name;
337 // underline commented fields and display a hover-title (CSS only)
339 if (isset($comments_map[$row['Field']])) {
340 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
343 if ($primary && $primary->hasColumn($field_name)) {
344 $displayed_field_name = '<u>' . $field_name . '</u>';
348 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
350 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo htmlspecialchars($row['Field']); ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
353 <?php
echo $rownum; ?
>
355 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $displayed_field_name; ?
></label
></th
>
356 <td
<?php
echo $type_nowrap; ?
>><bdo dir
="ltr" xml
:lang
="en"><?php
echo $type; echo $type_mime; ?
></bdo
></td
>
357 <td
><?php
echo (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?
></td
>
358 <td nowrap
="nowrap" class="column_attribute"><?php
echo $attribute; ?
></td
>
359 <td
><?php
echo (($row['Null'] == 'YES') ?
__('Yes') : __('No')); ?
></td
>
360 <td nowrap
="nowrap"><?php
361 if (isset($row['Default'])) {
362 if ($extracted_fieldspec['type'] == 'bit') {
363 // here, $row['Default'] contains something like b'010'
364 echo PMA_convert_bit_default_value($row['Default']);
366 echo $row['Default'];
369 echo '<i>' . _pgettext('None for default', 'None') . '</i>';
371 <td nowrap
="nowrap"><?php
echo strtoupper($row['Extra']); ?
></td
>
372 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
373 <td align
="center" class="edit">
374 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
375 <?php
echo $titles['Change']; ?
></a
>
377 <td align
="center" class="drop">
378 <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']))); ?>" >
379 <?php
echo $titles['Drop']; ?
></a
>
382 <td align
="center" class="browse replaced_by_more">
383 <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'])); ?>">
384 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
386 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
387 <td align
="center" class="primary replaced_by_more">
389 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
($primary && $primary->hasColumn($field_name))) {
390 echo $titles['NoPrimary'] . "\n";
391 $primary_enabled = false;
395 <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']))); ?>" >
396 <?php
echo $titles['Primary']; ?
></a
>
397 <?php
$primary_enabled = true;
402 <td align
="center" class="unique replaced_by_more">
404 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type ||
isset($columns_with_unique_index[$field_name])) {
405 echo $titles['NoUnique'] . "\n";
406 $unique_enabled = false;
410 <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']))); ?>">
411 <?php
echo $titles['Unique']; ?
></a
>
412 <?php
$unique_enabled = true;
417 <td align
="center" class="index replaced_by_more">
419 if ($type == 'text' ||
$type == 'blob' ||
'ARCHIVE' == $tbl_type) {
420 echo $titles['NoIndex'] . "\n";
421 $index_enabled = false;
425 <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']))); ?>">
426 <?php
echo $titles['Index']; ?
></a
>
428 $index_enabled = true;
434 if (!PMA_DRIZZLE
) { ?
>
435 <td align
="center" class="spatial replaced_by_more">
437 $spatial_types = array(
438 'geometry', 'point', 'linestring', 'polygon', 'multipoint',
439 'multilinestring', 'multipolygon', 'geomtrycollection'
441 if (! in_array($type, $spatial_types) ||
'MYISAM' != $tbl_type) {
442 echo $titles['NoSpatial'] . "\n";
443 $spatial_enabled = false;
447 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
448 <?php
echo $titles['Spatial']; ?
></a
>
450 $spatial_enabled = true;
456 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'ARIA' ||
$tbl_type == 'MARIA' ||
($tbl_type == 'INNODB' && PMA_MYSQL_INT_VERSION
>= 50604))
457 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
458 && (strpos(' ' . $type, 'text') ||
strpos(' ' . $type, 'char'))) {
461 <td align
="center" nowrap
="nowrap" class="fulltext replaced_by_more">
462 <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']))); ?>">
463 <?php
echo $titles['IdxFulltext']; ?
></a
>
464 <?php
$fulltext_enabled = true; ?
>
470 <td align
="center" nowrap
="nowrap" class="fulltext replaced_by_more">
471 <?php
echo $titles['NoIdxFulltext'] . "\n"; ?
>
472 <?php
$fulltext_enabled = false; ?
>
476 } // end if... else...
478 if ($GLOBALS['cfg']['PropertiesIconic'] !== true) { ?
>
479 <td
class="more_opts" id
="more_opts<?php echo $rownum; ?>">
480 <?php
echo PMA_getImage('more.png', __('Show more actions')); ?
> <?php
echo __('More'); ?
>
481 <div
class="structure_actions_dropdown" id
="row_<?php echo $rownum; ?>">
483 <div
class="action_browse replace_in_more">
484 <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'])); ?>">
485 <?php
echo $hidden_titles['BrowseDistinctValues']; ?
>
488 <div
class="<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'action_primary ' : ''); ?>replace_in_more">
490 if (isset($primary_enabled)) {
491 if ($primary_enabled) { ?
>
492 <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']))); ?>">
493 <?php
echo $hidden_titles['Primary']; ?
>
497 echo $hidden_titles['NoPrimary'];
501 <div
class="action_unique replace_in_more">
503 if (isset($unique_enabled)) {
504 if ($unique_enabled) { ?
>
505 <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']))); ?>">
506 <?php
echo $hidden_titles['Unique']; ?
>
510 echo $hidden_titles['NoUnique'];
514 <div
class="action_index replace_in_more">
516 if (isset($index_enabled)) {
517 if ($index_enabled) { ?
>
518 <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']))); ?>">
519 <?php
echo $hidden_titles['Index']; ?
>
523 echo $hidden_titles['NoIndex'];
527 <?php
if (!PMA_DRIZZLE
) { ?
>
528 <div
class="action_spatial replace_in_more">
530 if (isset($spatial_enabled)) {
531 if ($spatial_enabled) { ?
>
532 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ')'); ?>&message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
533 <?php
echo $hidden_titles['Spatial']; ?
>
537 echo $hidden_titles['NoSpatial'];
541 <div
class="action_fulltext replace_in_more">
543 if (isset($fulltext_enabled)) {
544 if ($fulltext_enabled) { ?
>
545 <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']))); ?>">
546 <?php
echo $hidden_titles['IdxFulltext']; ?
>
550 echo $hidden_titles['NoIdxFulltext'];
558 } // end if (GLOBALS['cfg']['PropertiesIconic'] !== true)
559 } // end if (! $tbl_is_view && ! $db_is_information_schema)
563 unset($field_charset);
566 echo '</tbody>' . "\n"
569 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
572 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
573 width
="38" height
="22" alt
="<?php echo __('With selected:'); ?>" />
574 <a href
="<?php echo $checkall_url; ?>&checkall=1"
575 onclick
="if (markAllRows('fieldsForm')) return false;">
576 <?php
echo __('Check All'); ?
></a
>
578 <a href
="<?php echo $checkall_url; ?>"
579 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
580 <?php
echo __('Uncheck All'); ?
></a
>
582 <i
><?php
echo __('With selected:'); ?
></i
>
585 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png', 'browse');
587 if (! $tbl_is_view && ! $db_is_information_schema) {
588 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png', 'change');
589 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png', 'drop');
590 if ('ARCHIVE' != $tbl_type) {
591 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png', 'primary');
592 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png', 'unique');
593 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png', 'index');
596 if (! empty($tbl_type) && $tbl_type == 'MYISAM') {
597 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_spatial', __('Spatial'), 'b_spatial.png', 'spatial');
599 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'ARIA' ||
$tbl_type == 'MARIA')) {
600 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png', 'ftext');
613 $create_view = PMA_DBI_get_definition($db, 'VIEW', $table);
614 $create_view = preg_replace('@^CREATE@', 'ALTER', $create_view);
615 echo PMA_linkOrButton(
616 'tbl_sql.php' . PMA_generate_common_url(
619 'sql_query' => $create_view,
623 PMA_getIcon('b_edit.png', __('Edit view'), true)
628 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
629 echo PMA_getIcon('b_print.png', __('Print view'), true);
633 if (! $tbl_is_view && ! $db_is_information_schema) {
635 // if internal relations are available, or foreign keys are supported
636 // ($tbl_type comes from libraries/tbl_info.inc.php)
637 if ($cfgRelation['relwork'] ||
PMA_foreignkey_supported($tbl_type)) {
639 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
640 echo PMA_getIcon('b_relations.png', __('Relation view'), true);
647 <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
648 echo PMA_getIcon('b_tblanalyse.png', __('Propose table structure'), true);
650 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
653 if (PMA_Tracker
::isActive()) {
654 echo '<a href="tbl_tracking.php?' . $url_query . '">';
655 echo PMA_getIcon('eye.png', __('Track table'), true);
661 <form method
="post" action
="tbl_addfield.php" id
="addColumns" name
="addColumns" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : '');?
>
662 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
664 echo PMA_generate_common_hidden_inputs($db, $table);
665 if ($cfg['PropertiesIconic']) {
666 echo PMA_getImage('b_insrow.png', __('Add column'));
668 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
670 // I tried displaying the drop-down inside the label but with Firefox
671 // the drop-down was blinking
672 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
673 foreach ($aryFields as $fieldname) {
674 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
677 $fieldOptions .= '</select>';
680 'last' => __('At End of Table'),
681 'first' => __('At Beginning of Table'),
682 'after' => sprintf(__('After %s'), '')
684 PMA_display_html_radio('field_where', $choices, 'last', false);
686 unset($fieldOptions, $choices);
688 <input type
="submit" value
="<?php echo __('Go'); ?>" />
690 <iframe
class="IE_hack" scrolling
="no"></iframe
>
692 <div id
="index_div" <?php
echo ($GLOBALS['cfg']['AjaxEnable'] ?
' class="ajax"' : ''); ?
> >
697 * If there are more than 20 rows, displays browse/select/insert/empty/drop
700 if (count($fields) > 20) {
701 include './libraries/tbl_links.inc.php';
702 } // end if (count($fields) > 20)
708 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
709 PMA_generate_slider_effect('indexes', __('Indexes'));
713 echo PMA_Index
::getView($table, $db);
715 <fieldset
class="tblFooters" style
="text-align: left;">
716 <form action
="./tbl_indexes.php" method
="post">
718 echo PMA_generate_common_hidden_inputs($db, $table);
719 echo sprintf(__('Create an index on %s columns'),
720 '<input type="text" size="2" name="added_fields" value="1" />');
722 <input type
="hidden" name
="create_index" value
="1" />
723 <input
class="add_index<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' ajax' : '');?>" type
="submit" value
="<?php echo __('Go'); ?>" />
732 * Displays Space usage and row statistics
734 // BEGIN - Calc Table Space
735 // Get valid statistics whatever is the table type
736 if ($cfg['ShowStats']) {
737 echo '<div id="tablestatistics">';
738 if (empty($showtable)) {
739 $showtable = PMA_Table
::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
743 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
744 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
750 $mergetable = PMA_Table
::isMerge($GLOBALS['db'], $GLOBALS['table']);
752 // this is to display for example 261.2 MiB instead of 268k KiB
755 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
756 if ($mergetable == false) {
757 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
759 // InnoDB returns a huge value in Data_free, do not use it
760 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
761 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
762 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
764 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
766 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'], $max_digits, $decimals);
767 if ($table_info_num_rows > 0) {
768 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
776 <legend
><?php
echo __('Information'); ?
></legend
>
777 <a name
="showusage"></a
>
778 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
779 <table id
="tablespaceusage" class="data">
780 <caption
class="tblHeaders"><?php
echo __('Space usage'); ?
></caption
>
783 <th
><?php
echo __('Type'); ?
></th
>
784 <th colspan
="2"><?php
echo __('Usage'); ?
></th
>
788 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
789 <th
class="name"><?php
echo __('Data'); ?
></th
>
790 <td
class="value"><?php
echo $data_size; ?
></td
>
791 <td
class="unit"><?php
echo $data_unit; ?
></td
>
794 if (isset($index_size)) {
796 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
797 <th
class="name"><?php
echo __('Index'); ?
></th
>
798 <td
class="value"><?php
echo $index_size; ?
></td
>
799 <td
class="unit"><?php
echo $index_unit; ?
></td
>
803 if (isset($free_size)) {
805 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> error">
806 <th
class="name"><?php
echo __('Overhead'); ?
></th
>
807 <td
class="value"><?php
echo $free_size; ?
></td
>
808 <td
class="unit"><?php
echo $free_unit; ?
></td
>
810 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
811 <th
class="name"><?php
echo __('Effective'); ?
></th
>
812 <td
class="value"><?php
echo $effect_size; ?
></td
>
813 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
817 if (isset($tot_size) && $mergetable == false) {
819 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
820 <th
class="name"><?php
echo __('Total'); ?
></th
>
821 <td
class="value"><?php
echo $tot_size; ?
></td
>
822 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
826 // Optimize link if overhead
827 if (isset($free_size) && !PMA_DRIZZLE
&& ($tbl_type == 'MYISAM' ||
$tbl_type == 'ARIA' ||
$tbl_type == 'MARIA' ||
$tbl_type == 'BDB')) {
829 <tr
class="tblFooters">
830 <td colspan
="3" align
="center">
831 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
832 echo PMA_getIcon('b_tbloptimize.png', __('Optimize table'));
845 <table id
="tablerowstats" class="data">
846 <caption
class="tblHeaders"><?php
echo __('Row Statistics'); ?
></caption
>
849 <th
><?php
echo __('Statements'); ?
></th
>
850 <th
><?php
echo __('Value'); ?
></th
>
855 if (isset($showtable['Row_format'])) {
857 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
858 <th
class="name"><?php
echo __('Format'); ?
></th
>
859 <td
class="value"><?php
860 if ($showtable['Row_format'] == 'Fixed') {
862 } elseif ($showtable['Row_format'] == 'Dynamic') {
865 echo $showtable['Row_format'];
871 if (! empty($showtable['Create_options'])) {
873 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
874 <th
class="name"><?php
echo __('Options'); ?
></th
>
875 <td
class="value"><?php
876 if ($showtable['Create_options'] == 'partitioned') {
877 echo __('partitioned');
879 echo $showtable['Create_options'];
885 if (!empty($tbl_collation)) {
887 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
888 <th
class="name"><?php
echo __('Collation'); ?
></th
>
889 <td
class="value"><?php
890 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
895 if (!$is_innodb && isset($showtable['Rows'])) {
897 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
898 <th
class="name"><?php
echo __('Rows'); ?
></th
>
899 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
903 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
905 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
906 <th
class="name"><?php
echo __('Row length'); ?
> ø
;</th
>
907 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
911 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
913 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
914 <th
class="name"><?php
echo __('Row size'); ?
> ø
;</th
>
915 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
919 if (isset($showtable['Auto_increment'])) {
921 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
922 <th
class="name"><?php
echo __('Next autoindex'); ?
></th
>
923 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
927 if (isset($showtable['Create_time'])) {
929 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
930 <th
class="name"><?php
echo __('Creation'); ?
></th
>
931 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
935 if (isset($showtable['Update_time'])) {
937 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
938 <th
class="name"><?php
echo __('Last update'); ?
></th
>
939 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
943 if (isset($showtable['Check_time'])) {
945 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
946 <th
class="name"><?php
echo __('Last check'); ?
></th
>
947 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
955 <!-- close tablestatistics div
-->
960 // END - Calc Table Space
962 echo '<div class="clearfloat"></div>' . "\n";
965 * Displays the footer
967 require './libraries/footer.inc.php';