Translation update done using Pootle.
[phpmyadmin-themes.git] / tbl_structure.php
blobc8e59d83d120611a896a5f0c56db4c7fb313a782
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Displays table structure infos like fields/columns, indexes, size, rows
5 * and allows manipulation of indexes and columns/fields
6 * @package phpMyAdmin
7 */
9 /**
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';
18 /**
19 * handle multiple field commands if required
21 * submit_mult_*_x comes from IE if <input type="img" ...> is used
23 if (isset($_REQUEST['submit_mult_change_x'])) {
24 $submit_mult = __('Change');
25 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
26 $submit_mult = __('Drop');
27 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
28 $submit_mult = __('Primary');
29 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
30 $submit_mult = __('Index');
31 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
32 $submit_mult = __('Unique');
33 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
34 $submit_mult = __('Fulltext');
35 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
36 $submit_mult = __('Browse');
37 } elseif (isset($_REQUEST['submit_mult'])) {
38 $submit_mult = $_REQUEST['submit_mult'];
39 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == __('Yes')) {
40 $submit_mult = 'row_delete';
41 if (isset($_REQUEST['selected'])) {
42 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
46 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
47 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
48 if ($submit_mult == __('Browse')) {
49 // browsing the table displaying only selected fields/columns
50 $GLOBALS['active_page'] = 'sql.php';
51 $sql_query = '';
52 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
53 if ($sql_query == '') {
54 $sql_query .= 'SELECT ' . PMA_backquote($sval);
55 } else {
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);
63 require './sql.php';
64 exit;
65 } else {
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();
79 /**
80 * Gets the relation settings
82 $cfgRelation = PMA_getRelationsParam();
84 /**
85 * Runs common work
87 require_once './libraries/tbl_common.php';
88 $url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
89 $url_params['goto'] = 'tbl_structure.php';
90 $url_params['back'] = 'tbl_structure.php';
92 /**
93 * Prepares the table structure display
97 /**
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);
123 // 3. Get fields
124 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
125 $fields_cnt = PMA_DBI_num_rows($fields_rs);
128 // Get more complete field information
129 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
130 // but later, if the analyser returns more information, it
131 // could be executed for any MySQL version and replace
132 // the info given by SHOW FULL FIELDS FROM.
134 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
135 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
136 // and SHOW CREATE TABLE says NOT NULL (tested
137 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
139 $show_create_table = PMA_DBI_fetch_value(
140 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
141 0, 1);
142 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
145 * prepare table infos
147 // action titles (image or string)
148 $titles = array();
149 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'), true);
150 $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
151 $titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'), true);
152 $titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), true);
153 $titles['Index'] = PMA_getIcon('b_index.png', __('Index'), true);
154 $titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), true);
155 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), true);
156 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), true);
157 $titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), true);
158 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), true);
159 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), true);
160 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), true);
162 // hidden action titles (image and string)
163 $hidden_titles = array();
164 $hidden_titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', __('Browse distinct values'), false, true);
165 $hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'), false, true);
166 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'), false, true);
167 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Index'), false, true);
168 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'), false, true);
169 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'), false, true);
170 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'), false, true);
171 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'), false, true);
172 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'), false, true);
175 * Displays the table structure ('show table' works correct since 3.23.03)
177 /* TABLE INFORMATION */
178 // table header
179 $i = 0;
181 <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm">
182 <?php echo PMA_generate_common_hidden_inputs($db, $table);
183 echo '<input type="hidden" name="table_type" value=';
184 if($db_is_information_schema) {
185 echo '"information_schema" />';
186 } else if ($tbl_is_view) {
187 echo '"view" />';
188 } else {
189 echo '"table" />';
190 } ?>
192 <table id="tablestructure" class="data">
193 <thead>
194 <tr>
195 <th id="th<?php echo ++$i; ?>"></th>
196 <th id="th<?php echo ++$i; ?>">#</th>
197 <th id="th<?php echo ++$i; ?>" class="column"><?php echo __('Column'); ?></th>
198 <th id="th<?php echo ++$i; ?>" class="type"><?php echo __('Type'); ?></th>
199 <th id="th<?php echo ++$i; ?>" class="collation"><?php echo __('Collation'); ?></th>
200 <th id="th<?php echo ++$i; ?>" class="attributes"><?php echo __('Attributes'); ?></th>
201 <th id="th<?php echo ++$i; ?>" class="null"><?php echo __('Null'); ?></th>
202 <th id="th<?php echo ++$i; ?>" class="default"><?php echo __('Default'); ?></th>
203 <th id="th<?php echo ++$i; ?>" class="extra"><?php echo __('Extra'); ?></th>
204 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
205 <th id="th<?php echo ++$i; ?>" class="view"><?php echo __('View'); ?></th>
206 <?php } else { ?>
207 <th colspan="7" id="th<?php echo ++$i; ?>" class="action"><?php echo __('Action'); ?></th>
208 <?php } ?>
209 </tr>
210 </thead>
211 <tbody>
213 <?php
214 unset($i);
216 // table body
218 // prepare comments
219 $comments_map = array();
220 $mime_map = array();
222 if ($GLOBALS['cfg']['ShowPropertyComments']) {
223 require_once './libraries/transformations.lib.php';
225 //$cfgRelation = PMA_getRelationsParam();
227 $comments_map = PMA_getComments($db, $table);
229 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
230 $mime_map = PMA_getMIME($db, $table, true);
234 $rownum = 0;
235 $aryFields = array();
236 $checked = (!empty($checkall) ? ' checked="checked"' : '');
237 $save_row = array();
238 $odd_row = true;
239 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
240 $save_row[] = $row;
241 $rownum++;
242 $aryFields[] = $row['Field'];
244 $type = $row['Type'];
245 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
247 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
248 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
250 // for the case ENUM('&#8211;','&ldquo;')
251 $type = htmlspecialchars($type);
252 if(strlen($type) > $GLOBALS['cfg']['LimitChars']) {
253 $type = '<abbr title="full text">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
256 $type_nowrap = '';
258 $binary = 0;
259 $unsigned = 0;
260 $zerofill = 0;
261 } else {
262 $type_nowrap = ' nowrap="nowrap"';
263 // strip the "BINARY" attribute, except if we find "BINARY(" because
264 // this would be a BINARY or VARBINARY field type
265 if (!preg_match('@BINARY[\(]@i', $type)) {
266 $type = preg_replace('@BINARY@i', '', $type);
268 $type = preg_replace('@ZEROFILL@i', '', $type);
269 $type = preg_replace('@UNSIGNED@i', '', $type);
270 if (empty($type)) {
271 $type = ' ';
274 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
275 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
276 } else {
277 $binary = false;
280 $unsigned = stristr($row['Type'], 'unsigned');
281 $zerofill = stristr($row['Type'], 'zerofill');
284 unset($field_charset);
285 if ((substr($type, 0, 4) == 'char'
286 || substr($type, 0, 7) == 'varchar'
287 || substr($type, 0, 4) == 'text'
288 || substr($type, 0, 8) == 'tinytext'
289 || substr($type, 0, 10) == 'mediumtext'
290 || substr($type, 0, 8) == 'longtext'
291 || substr($type, 0, 3) == 'set'
292 || substr($type, 0, 4) == 'enum'
293 ) && !$binary) {
294 if (strpos($type, ' character set ')) {
295 $type = substr($type, 0, strpos($type, ' character set '));
297 if (!empty($row['Collation'])) {
298 $field_charset = $row['Collation'];
299 } else {
300 $field_charset = '';
302 } else {
303 $field_charset = '';
306 // Display basic mimetype [MIME]
307 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
308 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
309 } else {
310 $type_mime = '';
313 $attribute = ' ';
314 if ($binary) {
315 $attribute = 'BINARY';
317 if ($unsigned) {
318 $attribute = 'UNSIGNED';
320 if ($zerofill) {
321 $attribute = 'UNSIGNED ZEROFILL';
324 // MySQL 4.1.2+ TIMESTAMP options
325 // (if on_update_current_timestamp is set, then it's TRUE)
326 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
327 $attribute = 'on update CURRENT_TIMESTAMP';
330 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
331 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
332 // the latter.
333 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']) {
334 $row['Null'] = '';
338 if (!isset($row['Default'])) {
339 if ($row['Null'] == 'YES') {
340 $row['Default'] = '<i>NULL</i>';
342 } else {
343 $row['Default'] = htmlspecialchars($row['Default']);
346 $field_encoded = urlencode($row['Field']);
347 $field_name = htmlspecialchars($row['Field']);
348 $displayed_field_name = $field_name;
350 // underline commented fields and display a hover-title (CSS only)
352 if (isset($comments_map[$row['Field']])) {
353 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
356 if ($primary && $primary->hasColumn($field_name)) {
357 $displayed_field_name = '<u>' . $field_name . '</u>';
359 echo "\n";
361 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
362 <td align="center">
363 <input type="checkbox" name="selected_fld[]" value="<?php echo htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
364 </td>
365 <td align="right">
366 <?php echo $rownum; ?>
367 </td>
368 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $displayed_field_name; ?></label></th>
369 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
370 <td><?php echo (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?></td>
371 <td nowrap="nowrap" class="column_attribute"><?php echo $attribute; ?></td>
372 <td><?php echo (($row['Null'] == 'YES') ? __('Yes') : __('No')); ?></td>
373 <td nowrap="nowrap"><?php
374 if (isset($row['Default'])) {
375 if ($extracted_fieldspec['type'] == 'bit') {
376 // here, $row['Default'] contains something like b'010'
377 echo PMA_convert_bit_default_value($row['Default']);
378 } else {
379 echo $row['Default'];
382 else {
383 echo '<i>' . _pgettext('None for default','None') . '</i>';
384 } ?></td>
385 <td nowrap="nowrap"><?php echo strtoupper($row['Extra']); ?></td>
386 <td align="center" class="browse">
387 <a href="sql.php?<?php echo $url_query; ?>&amp;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'])); ?>">
388 <?php echo $titles['BrowseDistinctValues']; ?></a>
389 </td>
390 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
391 <td align="center" class="edit">
392 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
393 <?php echo $titles['Change']; ?></a>
394 </td>
395 <td align="center" class="drop">
396 <a class="drop_column_anchor" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&amp;cpurge=1&amp;purgekey=<?php echo urlencode($row['Field']); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
397 <?php echo $titles['Drop']; ?></a>
398 </td>
399 <td align="center" class="primary">
400 <?php
401 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
402 echo $titles['NoPrimary'] . "\n";
403 $primary_enabled = false;
404 } else {
405 echo "\n";
407 <a class="add_primary_key_anchor" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
408 <?php echo $titles['Primary']; ?></a>
409 <?php $primary_enabled = true;
411 echo "\n";
413 </td>
414 <td align="center" class="unique">
415 <?php
416 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || isset($columns_with_unique_index[$field_name])) {
417 echo $titles['NoUnique'] . "\n";
418 $unique_enabled = false;
419 } else {
420 echo "\n";
422 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
423 <?php echo $titles['Unique']; ?></a>
424 <?php $unique_enabled = true;
426 echo "\n";
428 </td>
429 <td align="center" class="index">
430 <?php
431 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
432 echo $titles['NoIndex'] . "\n";
433 $index_enabled = false;
434 } else {
435 echo "\n";
437 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
438 <?php echo $titles['Index']; ?></a>
439 <?php
440 $index_enabled = true;
442 echo "\n";
444 </td>
445 <?php
446 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA')
447 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
448 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
449 echo "\n";
451 <td align="center" nowrap="nowrap" class="fulltext">
452 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
453 <?php echo $titles['IdxFulltext']; ?></a>
454 <?php $fulltext_enabled = true; ?>
455 </td>
456 <?php
457 } else {
458 echo "\n";
460 <td align="center" nowrap="nowrap" class="fulltext">
461 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
462 <?php $fulltext_enabled = false; ?>
463 </td>
464 <?php
465 } // end if... else...
466 echo "\n";
467 } // end if (! $tbl_is_view && ! $db_is_information_schema)
469 <td class="more_opts" id="more_opts<?php echo $rownum; ?>">
470 More <img src="<?php echo $pmaThemeImage . 'more.png'; ?>" alt="show more actions" />
471 <div class="structure_actions_dropdown" id="row_<?php echo $rownum; ?>">
473 <div class="action_browse">
474 <a href="sql.php?<?php echo $url_query; ?>&amp;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'])); ?>">
475 <?php echo $hidden_titles['BrowseDistinctValues']; ?>
476 </a>
477 </div>
478 <div class="action_primary">
479 <?php
480 if(isset($primary_enabled)) {
481 if($primary_enabled) { ?>
482 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
483 <?php echo $hidden_titles['Primary']; ?>
484 </a>
485 <?php
486 } else {
487 echo $hidden_titles['NoPrimary'];
489 } ?>
490 </div>
491 <div class="action_unique">
492 <?php
493 if(isset($unique_enabled)) {
494 if($unique_enabled) { ?>
495 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
496 <?php echo $hidden_titles['Unique']; ?>
497 </a>
498 <?php
499 } else {
500 echo $hidden_titles['NoUnique'];
502 } ?>
503 </div>
504 <div class="action_index">
505 <?php
506 if(isset($index_enabled)) {
507 if($index_enabled) { ?>
508 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
509 <?php echo $hidden_titles['Index']; ?>
510 </a>
511 <?php
512 } else {
513 echo $hidden_titles['NoIndex'];
515 } ?>
516 </div>
517 <div class="action_fulltext">
518 <?php
519 if(isset($fulltext_enabled)) {
520 if($fulltext_enabled) { ?>
521 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
522 <?php echo $hidden_titles['IdxFulltext']; ?>
523 </a>
524 <?php
525 } else {
526 echo $hidden_titles['NoIdxFulltext'];
528 } ?>
529 </div>
530 </div>
531 </td>
532 </tr>
533 <?php
534 unset($field_charset);
535 } // end while
537 echo '</tbody>' . "\n"
538 .'</table>' . "\n";
540 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
543 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
544 width="38" height="22" alt="<?php echo __('With selected:'); ?>" />
545 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
546 onclick="if (markAllRows('fieldsForm')) return false;">
547 <?php echo __('Check All'); ?></a>
549 <a href="<?php echo $checkall_url; ?>"
550 onclick="if (unMarkAllRows('fieldsForm')) return false;">
551 <?php echo __('Uncheck All'); ?></a>
553 <i><?php echo __('With selected:'); ?></i>
555 <?php
556 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png');
558 if (! $tbl_is_view && ! $db_is_information_schema) {
559 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png');
560 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png');
561 if ('ARCHIVE' != $tbl_type) {
562 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png');
563 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png');
564 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png');
566 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA')) {
567 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png');
571 </form>
572 <hr />
574 <?php
576 * Work on the table
579 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
580 if ($cfg['PropertiesIconic']) {
581 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
583 echo __('Print view');
584 ?></a>
586 <?php
587 if (! $tbl_is_view && ! $db_is_information_schema) {
589 // if internal relations are available, or foreign keys are supported
590 // ($tbl_type comes from libraries/tbl_info.inc.php)
591 if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) {
593 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
594 if ($cfg['PropertiesIconic']) {
595 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
597 echo __('Relation view');
598 ?></a>
599 <?php
602 <a href="sql.php?<?php echo $url_query; ?>&amp;session_max_rows=all&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
603 if ($cfg['PropertiesIconic']) {
604 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
606 echo __('Propose table structure');
607 ?></a><?php
608 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
611 if(PMA_Tracker::isActive())
613 echo '<a href="tbl_tracking.php?' . $url_query . '">';
615 if ($cfg['PropertiesIconic'])
617 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
619 echo __('Track table') . '</a>';
623 <br />
624 <form method="post" action="tbl_addfield.php"
625 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
626 <?php
627 echo PMA_generate_common_hidden_inputs($db, $table);
628 if ($cfg['PropertiesIconic']) {
629 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
631 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
633 // I tried displaying the drop-down inside the label but with Firefox
634 // the drop-down was blinking
635 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
636 foreach ($aryFields as $fieldname) {
637 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
639 unset($aryFields);
640 $fieldOptions .= '</select>';
642 $choices = array(
643 'last' => __('At End of Table'),
644 'first' => __('At Beginning of Table'),
645 'after' => sprintf(__('After %s'), '')
647 PMA_display_html_radio('field_where', $choices, 'last', false);
648 echo $fieldOptions;
649 unset($fieldOptions, $choices);
651 <input type="submit" value="<?php echo __('Go'); ?>" />
652 </form>
653 <iframe class="IE_hack" scrolling="no"></iframe>
654 <hr />
655 <?php
659 * If there are more than 20 rows, displays browse/select/insert/empty/drop
660 * links again
662 if ($fields_cnt > 20) {
663 require './libraries/tbl_links.inc.php';
664 } // end if ($fields_cnt > 20)
667 * Displays indexes
670 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
672 * Display indexes
674 echo PMA_Index::getView($table, $db);
676 <br />
677 <form action="./tbl_indexes.php" method="post"
678 onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
679 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
680 1)">
681 <fieldset>
682 <?php
683 echo PMA_generate_common_hidden_inputs($db, $table);
684 echo sprintf(__('Create an index on &nbsp;%s&nbsp;columns'),
685 '<input type="text" size="2" name="added_fields" value="1" />');
687 <input type="submit" name="create_index" value="<?php echo __('Go'); ?>"
688 onclick="return checkFormElementInRange(this.form,
689 'idx_num_fields',
690 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
691 1)" />
692 </fieldset>
693 </form>
694 <br />
695 <?php
698 PMA_generate_slider_effect('tablestatistics', __('Details...'));
701 * Displays Space usage and row statistics
703 // BEGIN - Calc Table Space
704 // Get valid statistics whatever is the table type
705 if ($cfg['ShowStats']) {
706 if (empty($showtable)) {
707 $showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
710 $nonisam = false;
711 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
712 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
713 $nonisam = true;
716 // Gets some sizes
718 $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
720 // this is to display for example 261.2 MiB instead of 268k KiB
721 $max_digits = 5;
722 $decimals = 1;
723 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
724 if ($mergetable == false) {
725 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
727 // InnoDB returns a huge value in Data_free, do not use it
728 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
729 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
730 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
731 } else {
732 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
734 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
735 if ($table_info_num_rows > 0) {
736 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
739 // Displays them
740 $odd_row = false;
743 <a name="showusage"></a>
744 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
745 <table id="tablespaceusage" class="data">
746 <caption class="tblHeaders"><?php echo __('Space usage'); ?></caption>
747 <thead>
748 <tr>
749 <th><?php echo __('Type'); ?></th>
750 <th colspan="2"><?php echo __('Usage'); ?></th>
751 </tr>
752 </thead>
753 <tbody>
754 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
755 <th class="name"><?php echo __('Data'); ?></th>
756 <td class="value"><?php echo $data_size; ?></td>
757 <td class="unit"><?php echo $data_unit; ?></td>
758 </tr>
759 <?php
760 if (isset($index_size)) {
762 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
763 <th class="name"><?php echo __('Index'); ?></th>
764 <td class="value"><?php echo $index_size; ?></td>
765 <td class="unit"><?php echo $index_unit; ?></td>
766 </tr>
767 <?php
769 if (isset($free_size)) {
771 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
772 <th class="name"><?php echo __('Overhead'); ?></th>
773 <td class="value"><?php echo $free_size; ?></td>
774 <td class="unit"><?php echo $free_unit; ?></td>
775 </tr>
776 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
777 <th class="name"><?php echo __('Effective'); ?></th>
778 <td class="value"><?php echo $effect_size; ?></td>
779 <td class="unit"><?php echo $effect_unit; ?></td>
780 </tr>
781 <?php
783 if (isset($tot_size) && $mergetable == false) {
785 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
786 <th class="name"><?php echo __('Total'); ?></th>
787 <td class="value"><?php echo $tot_size; ?></td>
788 <td class="unit"><?php echo $tot_unit; ?></td>
789 </tr>
790 <?php
792 // Optimize link if overhead
793 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA' || $tbl_type == 'BDB')) {
795 <tr class="tblFooters">
796 <td colspan="3" align="center">
797 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
798 if ($cfg['PropertiesIconic']) {
799 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
801 echo __('Optimize table');
802 ?></a>
803 </td>
804 </tr>
805 <?php
808 </tbody>
809 </table>
810 <?php
812 $odd_row = false;
814 <table id="tablerowstats" class="data">
815 <caption class="tblHeaders"><?php echo __('Row Statistics'); ?></caption>
816 <thead>
817 <tr>
818 <th><?php echo __('Statements'); ?></th>
819 <th><?php echo __('Value'); ?></th>
820 </tr>
821 </thead>
822 <tbody>
823 <?php
824 if (isset($showtable['Row_format'])) {
826 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
827 <th class="name"><?php echo __('Format'); ?></th>
828 <td class="value"><?php
829 if ($showtable['Row_format'] == 'Fixed') {
830 echo __('static');
831 } elseif ($showtable['Row_format'] == 'Dynamic') {
832 echo __('dynamic');
833 } else {
834 echo $showtable['Row_format'];
836 ?></td>
837 </tr>
838 <?php
840 if (! empty($showtable['Create_options'])) {
842 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
843 <th class="name"><?php echo __('Options'); ?></th>
844 <td class="value"><?php
845 if ($showtable['Create_options'] == 'partitioned') {
846 echo __('partitioned');
847 } else {
848 echo $showtable['Create_options'];
850 ?></td>
851 </tr>
852 <?php
854 if (!empty($tbl_collation)) {
856 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
857 <th class="name"><?php echo __('Collation'); ?></th>
858 <td class="value"><?php
859 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
860 ?></td>
861 </tr>
862 <?php
864 if (!$is_innodb && isset($showtable['Rows'])) {
866 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
867 <th class="name"><?php echo __('Rows'); ?></th>
868 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
869 </tr>
870 <?php
872 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
874 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
875 <th class="name"><?php echo __('Row length'); ?> &oslash;</th>
876 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
877 </tr>
878 <?php
880 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
882 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
883 <th class="name"><?php echo __(' Row size '); ?> &oslash;</th>
884 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
885 </tr>
886 <?php
888 if (isset($showtable['Auto_increment'])) {
890 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
891 <th class="name"><?php echo __('Next'); ?> Autoindex</th>
892 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
893 </tr>
894 <?php
896 if (isset($showtable['Create_time'])) {
898 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
899 <th class="name"><?php echo __('Creation'); ?></th>
900 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
901 </tr>
902 <?php
904 if (isset($showtable['Update_time'])) {
906 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
907 <th class="name"><?php echo __('Last update'); ?></th>
908 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
909 </tr>
910 <?php
912 if (isset($showtable['Check_time'])) {
914 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
915 <th class="name"><?php echo __('Last check'); ?></th>
916 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
917 </tr>
918 <?php
921 </tbody>
922 </table>
924 <!-- close slider div -->
925 </div>
927 <?php
929 // END - Calc Table Space
931 require './libraries/tbl_triggers.lib.php';
933 echo '<div class="clearfloat"></div>' . "\n";
936 * Displays the footer
938 require './libraries/footer.inc.php';