Translation update done using Pootle.
[phpmyadmin/bananer.git] / tbl_structure.php
blob001ac3301202569de6e86f15e67d0a0eaae8f852
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 * @version $Id$
7 * @package phpMyAdmin
8 */
10 /**
13 require_once './libraries/common.inc.php';
14 require_once './libraries/mysql_charsets.lib.php';
15 require_once './libraries/relation.lib.php';
17 $GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.min.js';
19 /**
20 * handle multiple field commands if required
22 * submit_mult_*_x comes from IE if <input type="img" ...> is used
24 if (isset($_REQUEST['submit_mult_change_x'])) {
25 $submit_mult = $strChange;
26 } elseif (isset($_REQUEST['submit_mult_drop_x'])) {
27 $submit_mult = $strDrop;
28 } elseif (isset($_REQUEST['submit_mult_primary_x'])) {
29 $submit_mult = $strPrimary;
30 } elseif (isset($_REQUEST['submit_mult_index_x'])) {
31 $submit_mult = $strIndex;
32 } elseif (isset($_REQUEST['submit_mult_unique_x'])) {
33 $submit_mult = $strUnique;
34 } elseif (isset($_REQUEST['submit_mult_fulltext_x'])) {
35 $submit_mult = $strIdxFulltext;
36 } elseif (isset($_REQUEST['submit_mult_browse_x'])) {
37 $submit_mult = $strBrowse;
38 } elseif (isset($_REQUEST['submit_mult'])) {
39 $submit_mult = $_REQUEST['submit_mult'];
40 } elseif (isset($_REQUEST['mult_btn']) && $_REQUEST['mult_btn'] == $strYes) {
41 $submit_mult = 'row_delete';
42 if (isset($_REQUEST['selected'])) {
43 $_REQUEST['selected_fld'] = $_REQUEST['selected'];
47 if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
48 $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
49 if ($submit_mult == $strBrowse) {
50 // browsing the table displaying only selected fields/columns
51 $GLOBALS['active_page'] = 'sql.php';
52 $sql_query = '';
53 foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
54 if ($sql_query == '') {
55 $sql_query .= 'SELECT ' . PMA_backquote($sval);
56 } else {
57 $sql_query .= ', ' . PMA_backquote($sval);
61 // what is this htmlspecialchars() for??
62 //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
63 $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
64 require './sql.php';
65 exit;
66 } else {
67 // handle multiple field commands
68 // handle confirmation of deleting multiple fields/columns
69 $action = 'tbl_structure.php';
70 require './libraries/mult_submits.inc.php';
71 //require_once './libraries/header.inc.php';
72 //require_once './libraries/tbl_links.inc.php';
74 if (empty($message)) {
75 $message = PMA_Message::success();
80 /**
81 * Gets the relation settings
83 $cfgRelation = PMA_getRelationsParam();
85 /**
86 * Runs common work
88 require_once './libraries/tbl_common.php';
89 $url_query .= '&amp;goto=tbl_structure.php&amp;back=tbl_structure.php';
90 $url_params['goto'] = 'tbl_structure.php';
91 $url_params['back'] = 'tbl_structure.php';
93 /**
94 * Prepares the table structure display
98 /**
99 * Gets tables informations
101 require_once './libraries/tbl_info.inc.php';
104 * Displays top menu links
106 require_once './libraries/tbl_links.inc.php';
107 require_once './libraries/Index.class.php';
109 // 2. Gets table keys and retains them
110 // @todo should be: $server->db($db)->table($table)->primary()
111 $primary = PMA_Index::getPrimary($table, $db);
113 $columns_with_unique_index = array();
114 foreach (PMA_Index::getFromTable($table, $db) as $index) {
115 if ($index->isUnique() && $index->getChoice() == 'UNIQUE') {
116 $columns = $index->getColumns();
117 foreach ($columns as $column_name => $dummy) {
118 $columns_with_unique_index[$column_name] = 1;
122 unset($index, $columns, $column_name, $dummy);
124 // 3. Get fields
125 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
126 $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),
142 0, 1);
143 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
146 * prepare table infos
148 // action titles (image or string)
149 $titles = array();
150 $titles['Change'] = PMA_getIcon('b_edit.png', $strChange, true);
151 $titles['Drop'] = PMA_getIcon('b_drop.png', $strDrop, true);
152 $titles['NoDrop'] = PMA_getIcon('b_drop.png', $strDrop, true);
153 $titles['Primary'] = PMA_getIcon('b_primary.png', $strPrimary, true);
154 $titles['Index'] = PMA_getIcon('b_index.png', $strIndex, true);
155 $titles['Unique'] = PMA_getIcon('b_unique.png', $strUnique, true);
156 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', $strIdxFulltext, true);
157 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', $strPrimary, true);
158 $titles['NoIndex'] = PMA_getIcon('bd_index.png', $strIndex, true);
159 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', $strUnique, true);
160 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', $strIdxFulltext, true);
161 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', $strBrowseDistinctValues, true);
164 * Displays the table structure ('show table' works correct since 3.23.03)
166 /* TABLE INFORMATION */
167 // table header
168 $i = 0;
170 <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm">
171 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
172 <table id="tablestructure" class="data">
173 <thead>
174 <tr>
175 <th id="th<?php echo ++$i; ?>"></th>
176 <th id="th<?php echo ++$i; ?>">#</th>
177 <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
178 <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
179 <th id="th<?php echo ++$i; ?>"><?php echo $strCollation; ?></th>
180 <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
181 <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
182 <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
183 <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
184 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
185 <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
186 <?php } else { ?>
187 <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
188 <?php } ?>
189 </tr>
190 </thead>
191 <tbody>
192 <?php
193 unset($i);
196 // table body
198 // prepare comments
199 $comments_map = array();
200 $mime_map = array();
202 if ($GLOBALS['cfg']['ShowPropertyComments']) {
203 require_once './libraries/relation.lib.php';
204 require_once './libraries/transformations.lib.php';
206 //$cfgRelation = PMA_getRelationsParam();
208 $comments_map = PMA_getComments($db, $table);
210 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
211 $mime_map = PMA_getMIME($db, $table, true);
215 $rownum = 0;
216 $aryFields = array();
217 $checked = (!empty($checkall) ? ' checked="checked"' : '');
218 $save_row = array();
219 $odd_row = true;
220 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
221 $save_row[] = $row;
222 $rownum++;
223 $aryFields[] = $row['Field'];
225 $type = $row['Type'];
226 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
228 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
229 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
231 // for the case ENUM('&#8211;','&ldquo;')
232 $type = htmlspecialchars($type);
234 $type_nowrap = '';
236 $binary = 0;
237 $unsigned = 0;
238 $zerofill = 0;
239 } else {
240 $type_nowrap = ' nowrap="nowrap"';
241 // strip the "BINARY" attribute, except if we find "BINARY(" because
242 // this would be a BINARY or VARBINARY field type
243 if (!preg_match('@BINARY[\(]@i', $type)) {
244 $type = preg_replace('@BINARY@i', '', $type);
246 $type = preg_replace('@ZEROFILL@i', '', $type);
247 $type = preg_replace('@UNSIGNED@i', '', $type);
248 if (empty($type)) {
249 $type = ' ';
252 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
253 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
254 } else {
255 $binary = false;
258 $unsigned = stristr($row['Type'], 'unsigned');
259 $zerofill = stristr($row['Type'], 'zerofill');
262 unset($field_charset);
263 if ((substr($type, 0, 4) == 'char'
264 || substr($type, 0, 7) == 'varchar'
265 || substr($type, 0, 4) == 'text'
266 || substr($type, 0, 8) == 'tinytext'
267 || substr($type, 0, 10) == 'mediumtext'
268 || substr($type, 0, 8) == 'longtext'
269 || substr($type, 0, 3) == 'set'
270 || substr($type, 0, 4) == 'enum'
271 ) && !$binary) {
272 if (strpos($type, ' character set ')) {
273 $type = substr($type, 0, strpos($type, ' character set '));
275 if (!empty($row['Collation'])) {
276 $field_charset = $row['Collation'];
277 } else {
278 $field_charset = '';
280 } else {
281 $field_charset = '';
284 // Display basic mimetype [MIME]
285 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
286 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
287 } else {
288 $type_mime = '';
291 $attribute = ' ';
292 if ($binary) {
293 $attribute = 'BINARY';
295 if ($unsigned) {
296 $attribute = 'UNSIGNED';
298 if ($zerofill) {
299 $attribute = 'UNSIGNED ZEROFILL';
302 // MySQL 4.1.2+ TIMESTAMP options
303 // (if on_update_current_timestamp is set, then it's TRUE)
304 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
305 $attribute = 'on update CURRENT_TIMESTAMP';
308 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
309 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
310 // the latter.
311 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']) {
312 $row['Null'] = '';
316 if (!isset($row['Default'])) {
317 if ($row['Null'] == 'YES') {
318 $row['Default'] = '<i>NULL</i>';
320 } else {
321 $row['Default'] = htmlspecialchars($row['Default']);
324 $field_encoded = urlencode($row['Field']);
325 $field_name = htmlspecialchars($row['Field']);
326 $displayed_field_name = $field_name;
328 // underline commented fields and display a hover-title (CSS only)
330 $comment_style = '';
331 if (isset($comments_map[$row['Field']])) {
332 $displayed_field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
335 if ($primary && $primary->hasColumn($field_name)) {
336 $displayed_field_name = '<u>' . $field_name . '</u>';
338 echo "\n";
340 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
341 <td align="center">
342 <input type="checkbox" name="selected_fld[]" value="<?php echo htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
343 </td>
344 <td align="right">
345 <?php echo $rownum; ?>
346 </td>
347 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $displayed_field_name; ?></label></th>
348 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
349 <td><?php echo (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?></td>
350 <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
351 <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
352 <td nowrap="nowrap"><?php
353 if (isset($row['Default'])) {
354 if ($extracted_fieldspec['type'] == 'bit') {
355 // here, $row['Default'] contains something like b'010'
356 echo PMA_convert_bit_default_value($row['Default']);
357 } else {
358 echo $row['Default'];
361 else {
362 echo '<i>' . $strNoneDefault . '</i>';
363 } ?></td>
364 <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
365 <td align="center">
366 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote($strRows) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
367 <?php echo $titles['BrowseDistinctValues']; ?></a>
368 </td>
369 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
370 <td align="center">
371 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
372 <?php echo $titles['Change']; ?></a>
373 </td>
374 <td align="center">
375 <a 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($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>"
376 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
377 <?php echo $titles['Drop']; ?></a>
378 </td>
379 <td align="center">
380 <?php
381 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
382 echo $titles['NoPrimary'] . "\n";
383 } else {
384 echo "\n";
386 <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($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
387 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
388 <?php echo $titles['Primary']; ?></a>
389 <?php
391 echo "\n";
393 </td>
394 <td align="center">
395 <?php
396 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || isset($columns_with_unique_index[$field_name])) {
397 echo $titles['NoUnique'] . "\n";
398 } else {
399 echo "\n";
401 <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($strAnIndex, htmlspecialchars($row['Field']))); ?>">
402 <?php echo $titles['Unique']; ?></a>
403 <?php
405 echo "\n";
407 </td>
408 <td align="center">
409 <?php
410 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
411 echo $titles['NoIndex'] . "\n";
412 } else {
413 echo "\n";
415 <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($strAnIndex, htmlspecialchars($row['Field']))); ?>">
416 <?php echo $titles['Index']; ?></a>
417 <?php
419 echo "\n";
421 </td>
422 <?php
423 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA')
424 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
425 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
426 echo "\n";
428 <td align="center" nowrap="nowrap">
429 <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($strAnIndex, htmlspecialchars($row['Field']))); ?>">
430 <?php echo $titles['IdxFulltext']; ?></a>
431 </td>
432 <?php
433 } else {
434 echo "\n";
436 <td align="center" nowrap="nowrap">
437 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
438 </td>
439 <?php
440 } // end if... else...
441 echo "\n";
442 } // end if (! $tbl_is_view && ! $db_is_information_schema)
444 </tr>
445 <?php
446 unset($field_charset);
447 } // end while
449 echo '</tbody>' . "\n"
450 .'</table>' . "\n";
452 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
455 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
456 width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
457 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
458 onclick="if (markAllRows('fieldsForm')) return false;">
459 <?php echo $strCheckAll; ?></a>
461 <a href="<?php echo $checkall_url; ?>"
462 onclick="if (unMarkAllRows('fieldsForm')) return false;">
463 <?php echo $strUncheckAll; ?></a>
465 <i><?php echo $strWithChecked; ?></i>
467 <?php
468 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
470 if (! $tbl_is_view && ! $db_is_information_schema) {
471 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
472 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
473 if ('ARCHIVE' != $tbl_type) {
474 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
475 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
476 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
478 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA')) {
479 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
483 </form>
484 <hr />
486 <?php
488 * Work on the table
491 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
492 if ($cfg['PropertiesIconic']) {
493 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
495 echo $strPrintView;
496 ?></a>
498 <?php
499 if (! $tbl_is_view && ! $db_is_information_schema) {
501 // if internal relations are available, or foreign keys are supported
502 // ($tbl_type comes from libraries/tbl_info.inc.php)
503 if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) {
505 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
506 if ($cfg['PropertiesIconic']) {
507 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
509 echo $strRelationView;
510 ?></a>
511 <?php
514 <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
515 if ($cfg['PropertiesIconic']) {
516 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
518 echo $strStructPropose;
519 ?></a><?php
520 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
523 if(PMA_Tracker::isActive())
525 echo '<a href="tbl_tracking.php?' . $url_query . '">';
527 if ($cfg['PropertiesIconic'])
529 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
531 echo $strTrackingTrackTable . '</a>';
535 <br />
536 <form method="post" action="tbl_addfield.php"
537 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
538 <?php
539 echo PMA_generate_common_hidden_inputs($db, $table);
540 if ($cfg['PropertiesIconic']) {
541 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
543 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
545 // I tried displaying the drop-down inside the label but with Firefox
546 // the drop-down was blinking
547 $fieldOptions = '<select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
548 foreach ($aryFields as $fieldname) {
549 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
551 unset($aryFields);
552 $fieldOptions .= '</select>';
554 $choices = array(
555 'last' => $strAtEndOfTable,
556 'first' => $strAtBeginningOfTable,
557 'after' => sprintf($strAfter, '')
559 PMA_display_html_radio('field_where', $choices, 'last', false);
560 echo $fieldOptions;
561 unset($fieldOptions, $choices);
563 <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
564 </form>
565 <hr />
566 <?php
570 * If there are more than 20 rows, displays browse/select/insert/empty/drop
571 * links again
573 if ($fields_cnt > 20) {
574 require './libraries/tbl_links.inc.php';
575 } // end if ($fields_cnt > 20)
578 * Displays indexes
581 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
583 * Display indexes
585 echo PMA_Index::getView($table, $db);
587 <br />
588 <form action="./tbl_indexes.php" method="post"
589 onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
590 '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
591 1)">
592 <fieldset>
593 <?php
594 echo PMA_generate_common_hidden_inputs($db, $table);
595 echo sprintf($strCreateIndex,
596 '<input type="text" size="2" name="added_fields" value="1" />');
598 <input type="submit" name="create_index" value="<?php echo $strGo; ?>"
599 onclick="return checkFormElementInRange(this.form,
600 'idx_num_fields',
601 '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
602 1)" />
603 </fieldset>
604 </form>
605 <br />
606 <?php
609 PMA_generate_slider_effect('tablestatistics', $strDetails);
612 * Displays Space usage and row statistics
614 // BEGIN - Calc Table Space
615 // Get valid statistics whatever is the table type
616 if ($cfg['ShowStats']) {
617 if (empty($showtable)) {
618 $showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
621 $nonisam = false;
622 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
623 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
624 $nonisam = true;
627 // Gets some sizes
629 $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
631 // this is to display for example 261.2 MiB instead of 268k KiB
632 $max_digits = 5;
633 $decimals = 1;
634 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
635 if ($mergetable == false) {
636 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
638 // InnoDB returns a huge value in Data_free, do not use it
639 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
640 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
641 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
642 } else {
643 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
645 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
646 if ($table_info_num_rows > 0) {
647 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
650 // Displays them
651 $odd_row = false;
654 <a name="showusage"></a>
655 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
656 <table id="tablespaceusage" class="data">
657 <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
658 <thead>
659 <tr>
660 <th><?php echo $strType; ?></th>
661 <th colspan="2"><?php echo $strUsage; ?></th>
662 </tr>
663 </thead>
664 <tbody>
665 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
666 <th class="name"><?php echo $strData; ?></th>
667 <td class="value"><?php echo $data_size; ?></td>
668 <td class="unit"><?php echo $data_unit; ?></td>
669 </tr>
670 <?php
671 if (isset($index_size)) {
673 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
674 <th class="name"><?php echo $strIndex; ?></th>
675 <td class="value"><?php echo $index_size; ?></td>
676 <td class="unit"><?php echo $index_unit; ?></td>
677 </tr>
678 <?php
680 if (isset($free_size)) {
682 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
683 <th class="name"><?php echo $strOverhead; ?></th>
684 <td class="value"><?php echo $free_size; ?></td>
685 <td class="unit"><?php echo $free_unit; ?></td>
686 </tr>
687 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
688 <th class="name"><?php echo $strEffective; ?></th>
689 <td class="value"><?php echo $effect_size; ?></td>
690 <td class="unit"><?php echo $effect_unit; ?></td>
691 </tr>
692 <?php
694 if (isset($tot_size) && $mergetable == false) {
696 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
697 <th class="name"><?php echo $strTotalUC; ?></th>
698 <td class="value"><?php echo $tot_size; ?></td>
699 <td class="unit"><?php echo $tot_unit; ?></td>
700 </tr>
701 <?php
703 // Optimize link if overhead
704 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'MARIA' || $tbl_type == 'BDB')) {
706 <tr class="tblFooters">
707 <td colspan="3" align="center">
708 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
709 if ($cfg['PropertiesIconic']) {
710 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
712 echo $strOptimizeTable;
713 ?></a>
714 </td>
715 </tr>
716 <?php
719 </tbody>
720 </table>
721 <?php
723 $odd_row = false;
725 <table id="tablerowstats" class="data">
726 <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
727 <thead>
728 <tr>
729 <th><?php echo $strStatement; ?></th>
730 <th><?php echo $strValue; ?></th>
731 </tr>
732 </thead>
733 <tbody>
734 <?php
735 if (isset($showtable['Row_format'])) {
737 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
738 <th class="name"><?php echo $strFormat; ?></th>
739 <td class="value"><?php
740 if ($showtable['Row_format'] == 'Fixed') {
741 echo $strStatic;
742 } elseif ($showtable['Row_format'] == 'Dynamic') {
743 echo $strDynamic;
744 } else {
745 echo $showtable['Row_format'];
747 ?></td>
748 </tr>
749 <?php
751 if (! empty($showtable['Create_options'])) {
753 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
754 <th class="name"><?php echo $strOptions; ?></th>
755 <td class="value"><?php
756 if ($showtable['Create_options'] == 'partitioned') {
757 echo $strPartitioned;
758 } else {
759 echo $showtable['Create_options'];
761 ?></td>
762 </tr>
763 <?php
765 if (!empty($tbl_collation)) {
767 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
768 <th class="name"><?php echo $strCollation; ?></th>
769 <td class="value"><?php
770 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
771 ?></td>
772 </tr>
773 <?php
775 if (!$is_innodb && isset($showtable['Rows'])) {
777 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
778 <th class="name"><?php echo $strRows; ?></th>
779 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
780 </tr>
781 <?php
783 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
785 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
786 <th class="name"><?php echo $strRowLength; ?> &oslash;</th>
787 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
788 </tr>
789 <?php
791 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
793 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
794 <th class="name"><?php echo $strRowSize; ?> &oslash;</th>
795 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
796 </tr>
797 <?php
799 if (isset($showtable['Auto_increment'])) {
801 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
802 <th class="name"><?php echo $strNext; ?> Autoindex</th>
803 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
804 </tr>
805 <?php
807 if (isset($showtable['Create_time'])) {
809 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
810 <th class="name"><?php echo $strStatCreateTime; ?></th>
811 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
812 </tr>
813 <?php
815 if (isset($showtable['Update_time'])) {
817 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
818 <th class="name"><?php echo $strStatUpdateTime; ?></th>
819 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
820 </tr>
821 <?php
823 if (isset($showtable['Check_time'])) {
825 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
826 <th class="name"><?php echo $strStatCheckTime; ?></th>
827 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
828 </tr>
829 <?php
832 </tbody>
833 </table>
835 <!-- close slider div -->
836 </div>
838 <?php
840 // END - Calc Table Space
842 require './libraries/tbl_triggers.lib.php';
844 echo '<div class="clearfloat"></div>' . "\n";
847 * Displays the footer
849 require_once './libraries/footer.inc.php';