3.3.9 release
[phpmyadmin/tyronm.git] / tbl_structure.php
blob3242d489868de6ef43eb0768de666c52870b04d6
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'][] = 'mootools.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);
114 // 3. Get fields
115 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
116 $fields_cnt = PMA_DBI_num_rows($fields_rs);
119 // Get more complete field information
120 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
121 // but later, if the analyser returns more information, it
122 // could be executed for any MySQL version and replace
123 // the info given by SHOW FULL FIELDS FROM.
125 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
126 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
127 // and SHOW CREATE TABLE says NOT NULL (tested
128 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
130 $show_create_table = PMA_DBI_fetch_value(
131 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
132 0, 1);
133 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
136 * prepare table infos
138 // action titles (image or string)
139 $titles = array();
140 $titles['Change'] = PMA_getIcon('b_edit.png', $strChange, true);
141 $titles['Drop'] = PMA_getIcon('b_drop.png', $strDrop, true);
142 $titles['NoDrop'] = PMA_getIcon('b_drop.png', $strDrop, true);
143 $titles['Primary'] = PMA_getIcon('b_primary.png', $strPrimary, true);
144 $titles['Index'] = PMA_getIcon('b_index.png', $strIndex, true);
145 $titles['Unique'] = PMA_getIcon('b_unique.png', $strUnique, true);
146 $titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', $strIdxFulltext, true);
147 $titles['NoPrimary'] = PMA_getIcon('bd_primary.png', $strPrimary, true);
148 $titles['NoIndex'] = PMA_getIcon('bd_index.png', $strIndex, true);
149 $titles['NoUnique'] = PMA_getIcon('bd_unique.png', $strUnique, true);
150 $titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', $strIdxFulltext, true);
151 $titles['BrowseDistinctValues'] = PMA_getIcon('b_browse.png', $strBrowseDistinctValues, true);
154 * Displays the table structure ('show table' works correct since 3.23.03)
156 /* TABLE INFORMATION */
157 // table header
158 $i = 0;
160 <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm">
161 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
162 <table id="tablestructure" class="data">
163 <thead>
164 <tr>
165 <th id="th<?php echo ++$i; ?>"></th>
166 <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
167 <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
168 <th id="th<?php echo ++$i; ?>"><?php echo $strCollation; ?></th>
169 <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
170 <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
171 <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
172 <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
173 <?php if ($db_is_information_schema || $tbl_is_view) { ?>
174 <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
175 <?php } else { ?>
176 <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
177 <?php } ?>
178 </tr>
179 </thead>
180 <tbody>
181 <?php
182 unset($i);
185 // table body
187 // prepare comments
188 $comments_map = array();
189 $mime_map = array();
191 if ($GLOBALS['cfg']['ShowPropertyComments']) {
192 require_once './libraries/relation.lib.php';
193 require_once './libraries/transformations.lib.php';
195 //$cfgRelation = PMA_getRelationsParam();
197 $comments_map = PMA_getComments($db, $table);
199 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
200 $mime_map = PMA_getMIME($db, $table, true);
204 $rownum = 0;
205 $aryFields = array();
206 $checked = (!empty($checkall) ? ' checked="checked"' : '');
207 $save_row = array();
208 $odd_row = true;
209 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
210 $save_row[] = $row;
211 $rownum++;
212 $aryFields[] = $row['Field'];
214 $type = $row['Type'];
215 $extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
217 if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
218 $type = $extracted_fieldspec['type'] . '(' . $extracted_fieldspec['spec_in_brackets'] . ')';
220 // for the case ENUM('&#8211;','&ldquo;')
221 $type = htmlspecialchars($type);
223 $type_nowrap = '';
225 $binary = 0;
226 $unsigned = 0;
227 $zerofill = 0;
228 } else {
229 $type_nowrap = ' nowrap="nowrap"';
230 // strip the "BINARY" attribute, except if we find "BINARY(" because
231 // this would be a BINARY or VARBINARY field type
232 if (!preg_match('@BINARY[\(]@i', $type)) {
233 $type = preg_replace('@BINARY@i', '', $type);
235 $type = preg_replace('@ZEROFILL@i', '', $type);
236 $type = preg_replace('@UNSIGNED@i', '', $type);
237 if (empty($type)) {
238 $type = ' ';
241 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
242 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
243 } else {
244 $binary = false;
247 $unsigned = stristr($row['Type'], 'unsigned');
248 $zerofill = stristr($row['Type'], 'zerofill');
251 unset($field_charset);
252 if ((substr($type, 0, 4) == 'char'
253 || substr($type, 0, 7) == 'varchar'
254 || substr($type, 0, 4) == 'text'
255 || substr($type, 0, 8) == 'tinytext'
256 || substr($type, 0, 10) == 'mediumtext'
257 || substr($type, 0, 8) == 'longtext'
258 || substr($type, 0, 3) == 'set'
259 || substr($type, 0, 4) == 'enum'
260 ) && !$binary) {
261 if (strpos($type, ' character set ')) {
262 $type = substr($type, 0, strpos($type, ' character set '));
264 if (!empty($row['Collation'])) {
265 $field_charset = $row['Collation'];
266 } else {
267 $field_charset = '';
269 } else {
270 $field_charset = '';
273 // garvin: Display basic mimetype [MIME]
274 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
275 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
276 } else {
277 $type_mime = '';
280 $attribute = ' ';
281 if ($binary) {
282 $attribute = 'BINARY';
284 if ($unsigned) {
285 $attribute = 'UNSIGNED';
287 if ($zerofill) {
288 $attribute = 'UNSIGNED ZEROFILL';
291 // MySQL 4.1.2+ TIMESTAMP options
292 // (if on_update_current_timestamp is set, then it's TRUE)
293 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
294 $attribute = 'on update CURRENT_TIMESTAMP';
297 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
298 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
299 // the latter.
300 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']) {
301 $row['Null'] = '';
305 if (!isset($row['Default'])) {
306 if ($row['Null'] == 'YES') {
307 $row['Default'] = '<i>NULL</i>';
309 } else {
310 $row['Default'] = htmlspecialchars($row['Default']);
313 $field_encoded = urlencode($row['Field']);
314 $field_name = htmlspecialchars($row['Field']);
316 // garvin: underline commented fields and display a hover-title (CSS only)
318 $comment_style = '';
319 if (isset($comments_map[$row['Field']])) {
320 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
323 if ($primary && $primary->hasColumn($field_name)) {
324 $field_name = '<u>' . $field_name . '</u>';
326 echo "\n";
328 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
329 <td align="center">
330 <input type="checkbox" name="selected_fld[]" value="<?php echo htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
331 </td>
332 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th>
333 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
334 <td><?php echo (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?></td>
335 <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
336 <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
337 <td nowrap="nowrap"><?php
338 if (isset($row['Default'])) {
339 if ($extracted_fieldspec['type'] == 'bit') {
340 // here, $row['Default'] contains something like b'010'
341 echo PMA_convert_bit_default_value($row['Default']);
342 } else {
343 echo $row['Default'];
346 else {
347 echo '<i>' . $strNoneDefault . '</i>';
348 } ?></td>
349 <td nowrap="nowrap"><?php echo strtoupper($row['Extra']); ?></td>
350 <td align="center">
351 <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'])); ?>">
352 <?php echo $titles['BrowseDistinctValues']; ?></a>
353 </td>
354 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
355 <td align="center">
356 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
357 <?php echo $titles['Change']; ?></a>
358 </td>
359 <td align="center">
360 <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']))); ?>"
361 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
362 <?php echo $titles['Drop']; ?></a>
363 </td>
364 <td align="center">
365 <?php
366 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
367 echo $titles['NoPrimary'] . "\n";
368 } else {
369 echo "\n";
371 <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']))); ?>"
372 onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . ($primary ? ' DROP PRIMARY KEY,' : ''); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
373 <?php echo $titles['Primary']; ?></a>
374 <?php
376 echo "\n";
378 </td>
379 <td align="center">
380 <?php
381 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
382 echo $titles['NoUnique'] . "\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) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
387 <?php echo $titles['Unique']; ?></a>
388 <?php
390 echo "\n";
392 </td>
393 <td align="center">
394 <?php
395 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
396 echo $titles['NoIndex'] . "\n";
397 } else {
398 echo "\n";
400 <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']))); ?>">
401 <?php echo $titles['Index']; ?></a>
402 <?php
404 echo "\n";
406 </td>
407 <?php
408 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')
409 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
410 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
411 echo "\n";
413 <td align="center" nowrap="nowrap">
414 <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']))); ?>">
415 <?php echo $titles['IdxFulltext']; ?></a>
416 </td>
417 <?php
418 } else {
419 echo "\n";
421 <td align="center" nowrap="nowrap">
422 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
423 </td>
424 <?php
425 } // end if... else...
426 echo "\n";
427 } // end if (! $tbl_is_view && ! $db_is_information_schema)
429 </tr>
430 <?php
431 unset($field_charset);
432 } // end while
434 echo '</tbody>' . "\n"
435 .'</table>' . "\n";
437 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
440 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
441 width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
442 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
443 onclick="if (markAllRows('fieldsForm')) return false;">
444 <?php echo $strCheckAll; ?></a>
446 <a href="<?php echo $checkall_url; ?>"
447 onclick="if (unMarkAllRows('fieldsForm')) return false;">
448 <?php echo $strUncheckAll; ?></a>
450 <i><?php echo $strWithChecked; ?></i>
452 <?php
453 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
455 if (! $tbl_is_view && ! $db_is_information_schema) {
456 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
457 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
458 if ('ARCHIVE' != $tbl_type) {
459 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
460 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
461 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
463 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')) {
464 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
468 </form>
469 <hr />
471 <?php
473 * Work on the table
476 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
477 if ($cfg['PropertiesIconic']) {
478 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
480 echo $strPrintView;
481 ?></a>
483 <?php
484 if (! $tbl_is_view && ! $db_is_information_schema) {
486 // if internal relations are available, or foreign keys are supported
487 // ($tbl_type comes from libraries/tbl_info.inc.php)
488 if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) {
490 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
491 if ($cfg['PropertiesIconic']) {
492 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
494 echo $strRelationView;
495 ?></a>
496 <?php
499 <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
500 if ($cfg['PropertiesIconic']) {
501 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
503 echo $strStructPropose;
504 ?></a><?php
505 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
508 if(PMA_Tracker::isActive())
510 echo '<a href="tbl_tracking.php?' . $url_query . '">';
512 if ($cfg['PropertiesIconic'])
514 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . $strTrackingTrackTable . '" /> ';
516 echo $strTrackingTrackTable . '</a>';
520 <br />
521 <form method="post" action="tbl_addfield.php"
522 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
523 <?php
524 echo PMA_generate_common_hidden_inputs($db, $table);
525 if ($cfg['PropertiesIconic']) {
526 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
528 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
530 // I tried displaying the drop-down inside the label but with Firefox
531 // the drop-down was blinking
532 $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">';
533 foreach ($aryFields as $fieldname) {
534 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
536 unset($aryFields);
537 $fieldOptions .= '</select>';
539 $choices = array(
540 'last' => $strAtEndOfTable,
541 'first' => $strAtBeginningOfTable,
542 'after' => sprintf($strAfter, '')
544 PMA_display_html_radio('field_where', $choices, 'last', false);
545 echo $fieldOptions;
546 unset($fieldOptions, $choices);
548 <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
549 </form>
550 <hr />
551 <?php
555 * If there are more than 20 rows, displays browse/select/insert/empty/drop
556 * links again
558 if ($fields_cnt > 20) {
559 require './libraries/tbl_links.inc.php';
560 } // end if ($fields_cnt > 20)
563 * Displays indexes
566 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
568 * Display indexes
570 echo PMA_Index::getView($table, $db);
572 <br />
573 <form action="./tbl_indexes.php" method="post"
574 onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
575 '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
576 1)">
577 <fieldset>
578 <?php
579 echo PMA_generate_common_hidden_inputs($db, $table);
580 echo sprintf($strCreateIndex,
581 '<input type="text" size="2" name="added_fields" value="1" />');
583 <input type="submit" name="create_index" value="<?php echo $strGo; ?>"
584 onclick="return checkFormElementInRange(this.form,
585 'idx_num_fields',
586 '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidColumnCount']); ?>',
587 1)" />
588 </fieldset>
589 </form>
590 <br />
591 <?php
594 PMA_generate_slider_effect('tablestatistics', $strDetails);
597 * Displays Space usage and row statistics
599 // BEGIN - Calc Table Space - staybyte - 9 June 2001
600 // loic1, 22 feb. 2002: updated with patch from
601 // Joshua Nye <josh at boxcarmedia.com> to get valid
602 // statistics whatever is the table type
603 if ($cfg['ShowStats']) {
604 if (empty($showtable)) {
605 $showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
608 $nonisam = false;
609 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
610 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
611 $nonisam = true;
614 // Gets some sizes
616 $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
618 // this is to display for example 261.2 MiB instead of 268k KiB
619 $max_digits = 5;
620 $decimals = 1;
621 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
622 if ($mergetable == false) {
623 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
625 // InnoDB returns a huge value in Data_free, do not use it
626 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
627 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
628 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
629 } else {
630 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
632 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
633 if ($table_info_num_rows > 0) {
634 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
637 // Displays them
638 $odd_row = false;
641 <a name="showusage"></a>
642 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
643 <table id="tablespaceusage" class="data">
644 <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
645 <thead>
646 <tr>
647 <th><?php echo $strType; ?></th>
648 <th colspan="2"><?php echo $strUsage; ?></th>
649 </tr>
650 </thead>
651 <tbody>
652 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
653 <th class="name"><?php echo $strData; ?></th>
654 <td class="value"><?php echo $data_size; ?></td>
655 <td class="unit"><?php echo $data_unit; ?></td>
656 </tr>
657 <?php
658 if (isset($index_size)) {
660 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
661 <th class="name"><?php echo $strIndex; ?></th>
662 <td class="value"><?php echo $index_size; ?></td>
663 <td class="unit"><?php echo $index_unit; ?></td>
664 </tr>
665 <?php
667 if (isset($free_size)) {
669 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
670 <th class="name"><?php echo $strOverhead; ?></th>
671 <td class="value"><?php echo $free_size; ?></td>
672 <td class="unit"><?php echo $free_unit; ?></td>
673 </tr>
674 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
675 <th class="name"><?php echo $strEffective; ?></th>
676 <td class="value"><?php echo $effect_size; ?></td>
677 <td class="unit"><?php echo $effect_unit; ?></td>
678 </tr>
679 <?php
681 if (isset($tot_size) && $mergetable == false) {
683 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
684 <th class="name"><?php echo $strTotalUC; ?></th>
685 <td class="value"><?php echo $tot_size; ?></td>
686 <td class="unit"><?php echo $tot_unit; ?></td>
687 </tr>
688 <?php
690 // Optimize link if overhead
691 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA' || $tbl_type == 'BDB')) {
693 <tr class="tblFooters">
694 <td colspan="3" align="center">
695 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
696 if ($cfg['PropertiesIconic']) {
697 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
699 echo $strOptimizeTable;
700 ?></a>
701 </td>
702 </tr>
703 <?php
706 </tbody>
707 </table>
708 <?php
710 $odd_row = false;
712 <table id="tablerowstats" class="data">
713 <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
714 <thead>
715 <tr>
716 <th><?php echo $strStatement; ?></th>
717 <th><?php echo $strValue; ?></th>
718 </tr>
719 </thead>
720 <tbody>
721 <?php
722 if (isset($showtable['Row_format'])) {
724 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
725 <th class="name"><?php echo $strFormat; ?></th>
726 <td class="value"><?php
727 if ($showtable['Row_format'] == 'Fixed') {
728 echo $strStatic;
729 } elseif ($showtable['Row_format'] == 'Dynamic') {
730 echo $strDynamic;
731 } else {
732 echo $showtable['Row_format'];
734 ?></td>
735 </tr>
736 <?php
738 if (! empty($showtable['Create_options'])) {
740 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
741 <th class="name"><?php echo $strOptions; ?></th>
742 <td class="value"><?php
743 if ($showtable['Create_options'] == 'partitioned') {
744 echo $strPartitioned;
745 } else {
746 echo $showtable['Create_options'];
748 ?></td>
749 </tr>
750 <?php
752 if (!empty($tbl_collation)) {
754 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
755 <th class="name"><?php echo $strCollation; ?></th>
756 <td class="value"><?php
757 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
758 ?></td>
759 </tr>
760 <?php
762 if (!$is_innodb && isset($showtable['Rows'])) {
764 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
765 <th class="name"><?php echo $strRows; ?></th>
766 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
767 </tr>
768 <?php
770 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
772 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
773 <th class="name"><?php echo $strRowLength; ?> &oslash;</th>
774 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
775 </tr>
776 <?php
778 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
780 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
781 <th class="name"><?php echo $strRowSize; ?> &oslash;</th>
782 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
783 </tr>
784 <?php
786 if (isset($showtable['Auto_increment'])) {
788 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
789 <th class="name"><?php echo $strNext; ?> Autoindex</th>
790 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
791 </tr>
792 <?php
794 if (isset($showtable['Create_time'])) {
796 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
797 <th class="name"><?php echo $strStatCreateTime; ?></th>
798 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
799 </tr>
800 <?php
802 if (isset($showtable['Update_time'])) {
804 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
805 <th class="name"><?php echo $strStatUpdateTime; ?></th>
806 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
807 </tr>
808 <?php
810 if (isset($showtable['Check_time'])) {
812 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
813 <th class="name"><?php echo $strStatCheckTime; ?></th>
814 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
815 </tr>
816 <?php
819 </tbody>
820 </table>
821 <?php
823 // END - Calc Table Space
825 require './libraries/tbl_triggers.lib.php';
827 echo '<div class="clearfloat"></div>' . "\n";
830 * Displays the footer
832 require_once './libraries/footer.inc.php';