3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once './libraries/common.lib.php';
6 require_once './libraries/mysql_charsets.lib.php';
7 require_once './libraries/relation.lib.php';
10 * Gets the relation settings
12 $cfgRelation = PMA_getRelationsParam();
16 * Drop multiple fields if required
19 // workaround for IE problem:
20 if (isset($submit_mult_change_x)) {
21 $submit_mult = $strChange;
22 } elseif (isset($submit_mult_drop_x)) {
23 $submit_mult = $strDrop;
24 } elseif (isset($submit_mult_primary_x)) {
25 $submit_mult = $strPrimary;
26 } elseif (isset($submit_mult_index_x)) {
27 $submit_mult = $strIndex;
28 } elseif (isset($submit_mult_unique_x)) {
29 $submit_mult = $strUnique;
30 } elseif (isset($submit_mult_fulltext_x)) {
31 $submit_mult = $strIdxFulltext;
34 if ((!empty($submit_mult) && isset($selected_fld))
35 ||
isset($mult_btn)) {
36 $action = 'tbl_properties_structure.php';
37 $err_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
38 require './libraries/mult_submits.inc.php';
44 require_once './libraries/tbl_properties_common.php';
45 $url_query .= '&goto=tbl_properties_structure.php&back=tbl_properties_structure.php';
48 * Prepares the table structure display
52 * Gets tables informations
54 require_once './libraries/tbl_properties_table_info.inc.php';
57 * Show result of multi submit operation
59 if ((!empty($submit_mult) && isset($selected_fld))
60 ||
isset($mult_btn)) {
61 $message = $strSuccess;
65 * Displays top menu links
67 require_once './libraries/tbl_properties_links.inc.php';
69 // 2. Gets table keys and retains them
70 $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table) . ';');
73 $pk_array = array(); // will be use to emphasis prim. keys in the table view
74 while ($row = PMA_DBI_fetch_assoc($result)) {
76 // Backups the list of primary keys
77 if ($row['Key_name'] == 'PRIMARY') {
78 $primary .= $row['Column_name'] . ', ';
79 $pk_array[$row['Column_name']] = 1;
82 PMA_DBI_free_result($result);
85 $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
86 $fields_cnt = PMA_DBI_num_rows($fields_rs);
88 // Get more complete field information
89 // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
90 // but later, if the analyser returns more information, it
91 // could be executed for any MySQL version and replace
92 // the info given by SHOW FULL FIELDS FROM.
94 // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
95 // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
96 // and SHOW CREATE TABLE says NOT NULL (tested
97 // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
99 $show_create_table = PMA_DBI_fetch_value(
100 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
102 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
105 * prepare table infos
107 // action titles (image or string)
109 if ($cfg['PropertiesIconic'] == true) {
110 if ($cfg['PropertiesIconic'] === 'both') {
111 $iconic_spacer = '<div class="nowrap">';
116 // images replaced 2004-05-08 by mkkeck
117 $titles['Change'] = $iconic_spacer
118 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
119 . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />';
120 $titles['Drop'] = $iconic_spacer
121 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
122 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
123 $titles['NoDrop'] = $iconic_spacer
124 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
125 . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
126 $titles['Primary'] = $iconic_spacer
127 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
128 . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
129 $titles['Index'] = $iconic_spacer
130 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
131 . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
132 $titles['Unique'] = $iconic_spacer
133 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
134 . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
135 $titles['IdxFulltext'] = $iconic_spacer
136 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
137 . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
138 $titles['NoPrimary'] = $iconic_spacer
139 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
140 . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
141 $titles['NoIndex'] = $iconic_spacer
142 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
143 . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
144 $titles['NoUnique'] = $iconic_spacer
145 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
146 . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
147 $titles['NoIdxFulltext'] = $iconic_spacer
148 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
149 . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
150 $titles['BrowseDistinctValues'] = $iconic_spacer
151 . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
152 . 'b_browse.png" alt="' . $strBrowseDistinctValues . '" title="' . $strBrowseDistinctValues . '" />';
154 if ($cfg['PropertiesIconic'] === 'both') {
155 $titles['Change'] .= $strChange . '</div>';
156 $titles['Drop'] .= $strDrop . '</div>';
157 $titles['NoDrop'] .= $strDrop . '</div>';
158 $titles['Primary'] .= $strPrimary . '</div>';
159 $titles['Index'] .= $strIndex . '</div>';
160 $titles['Unique'] .= $strUnique . '</div>';
161 $titles['IdxFulltext' ] .= $strIdxFulltext . '</div>';
162 $titles['NoPrimary'] .= $strPrimary . '</div>';
163 $titles['NoIndex'] .= $strIndex . '</div>';
164 $titles['NoUnique'] .= $strUnique . '</div>';
165 $titles['NoIdxFulltext'] .= $strIdxFulltext . '</div>';
166 $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . '</div>';
169 $titles['Change'] = $strChange;
170 $titles['Drop'] = $strDrop;
171 $titles['NoDrop'] = $strDrop;
172 $titles['Primary'] = $strPrimary;
173 $titles['Index'] = $strIndex;
174 $titles['Unique'] = $strUnique;
175 $titles['IdxFulltext'] = $strIdxFulltext;
176 $titles['NoPrimary'] = $strPrimary;
177 $titles['NoIndex'] = $strIndex;
178 $titles['NoUnique'] = $strUnique;
179 $titles['NoIdxFulltext'] = $strIdxFulltext;
180 $titles['BrowseDistinctValues'] = $strBrowseDistinctValues;
184 * Displays the table structure ('show table' works correct since 3.23.03)
186 /* TABLE INFORMATION */
190 <form method
="post" action
="tbl_properties_structure.php" name
="fieldsForm" id
="fieldsForm">
191 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
192 <table id
="tablestructure" class="data">
195 <th id
="th<?php echo ++$i; ?>"></th
>
196 <th id
="th<?php echo ++$i; ?>"><?php
echo $strField; ?
></th
>
197 <th id
="th<?php echo ++$i; ?>"><?php
echo $strType; ?
></th
>
198 <?php
echo PMA_MYSQL_INT_VERSION
>= 40100 ?
' <th id="th' . ++
$i . '">' . $strCollation . '</th>' . "\n" : ''; ?
>
199 <th id
="th<?php echo ++$i; ?>"><?php
echo $strAttr; ?
></th
>
200 <th id
="th<?php echo ++$i; ?>"><?php
echo $strNull; ?
></th
>
201 <th id
="th<?php echo ++$i; ?>"><?php
echo $strDefault; ?
></th
>
202 <th id
="th<?php echo ++$i; ?>"><?php
echo $strExtra; ?
></th
>
203 <?php
if ($db_is_information_schema ||
$tbl_is_view) { ?
>
204 <th id
="th<?php echo ++$i; ?>"><?php
echo $strView; ?
></th
>
206 <th colspan
="7" id
="th<?php echo ++$i; ?>"><?php
echo $strAction; ?
></th
>
218 $comments_map = array();
221 if ($GLOBALS['cfg']['ShowPropertyComments']) {
222 require_once './libraries/relation.lib.php';
223 require_once './libraries/transformations.lib.php';
225 $cfgRelation = PMA_getRelationsParam();
227 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
228 $comments_map = PMA_getComments($db, $table);
230 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
231 $mime_map = PMA_getMIME($db, $table, true);
237 $aryFields = array();
238 $checked = (!empty($checkall) ?
' checked="checked"' : '');
241 while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
244 $aryFields[] = $row['Field'];
246 $type = $row['Type'];
247 // reformat mysql query output - staybyte - 9. June 2001
248 // loic1: set or enum types: slashes single quotes inside options
249 if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
250 $tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
251 $type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
253 // for the case ENUM('–','“')
254 $type = htmlspecialchars($type);
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);
274 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
275 $binary = stristr($row['Type'], 'blob') ||
stristr($row['Type'], 'binary');
280 $unsigned = stristr($row['Type'], 'unsigned');
281 $zerofill = stristr($row['Type'], 'zerofill');
284 // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1)
285 unset($field_charset);
286 if (PMA_MYSQL_INT_VERSION
>= 40100) {
287 if ((substr($type, 0, 4) == 'char'
288 ||
substr($type, 0, 7) == 'varchar'
289 ||
substr($type, 0, 4) == 'text'
290 ||
substr($type, 0, 8) == 'tinytext'
291 ||
substr($type, 0, 10) == 'mediumtext'
292 ||
substr($type, 0, 8) == 'longtext'
293 ||
substr($type, 0, 3) == 'set'
294 ||
substr($type, 0, 4) == 'enum'
296 if (strpos($type, ' character set ')) {
297 $type = substr($type, 0, strpos($type, ' character set '));
299 if (!empty($row['Collation'])) {
300 $field_charset = $row['Collation'];
309 // garvin: Display basic mimetype [MIME]
310 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
311 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
318 $attribute = 'BINARY';
321 $attribute = 'UNSIGNED';
324 $attribute = 'UNSIGNED ZEROFILL';
327 // MySQL 4.1.2+ TIMESTAMP options
328 // (if on_update_current_timestamp is set, then it's TRUE)
329 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
330 $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
333 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
334 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
336 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']) {
341 if (!isset($row['Default'])) {
342 if ($row['Null'] == 'YES') {
343 $row['Default'] = '<i>NULL</i>';
346 $row['Default'] = htmlspecialchars($row['Default']);
349 $field_encoded = urlencode($row['Field']);
350 $field_name = htmlspecialchars($row['Field']);
352 // garvin: underline commented fields and display a hover-title (CSS only)
355 if (isset($comments_map[$row['Field']])) {
356 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
359 if (isset($pk_array[$row['Field']])) {
360 $field_name = '<u>' . $field_name . '</u>';
364 <tr
class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
366 <input type
="checkbox" name
="selected_fld[]" value
="<?php echo $field_encoded; ?>" id
="checkbox_row_<?php echo $rownum; ?>" <?php
echo $checked; ?
> />
368 <th nowrap
="nowrap"><label
for="checkbox_row_<?php echo $rownum; ?>"><?php
echo $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 <?php
echo PMA_MYSQL_INT_VERSION
>= 40100 ?
' <td>' . (empty($field_charset) ?
'' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?
>
371 <td nowrap
="nowrap" style
="font-size: 70%"><?php
echo $attribute; ?
></td
>
372 <td
><?php
echo (($row['Null'] == 'YES') ?
$strYes : $strNo); ?
></td
>
373 <td nowrap
="nowrap"><?php
if (isset($row['Default'])) { echo $row['Default']; } ?
></td
>
374 <td nowrap
="nowrap"><?php
echo $row['Extra']; ?
></td
>
376 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT COUNT(*) AS `' . $strRows . '`, `' . $row['Field'] . '` FROM `' . $table . '` GROUP BY `' . $row['Field'] . '` ORDER BY `' . $row['Field'] . '`'); ?>">
377 <?php
echo $titles['BrowseDistinctValues']; ?
></a
>
379 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
381 <a href
="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
382 <?php
echo $titles['Change']; ?
></a
>
386 // loic1: Drop field only if there is more than one field in the table
387 if ($fields_cnt > 1) {
390 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&cpurge=1&purgekey=<?php echo urlencode($row['Field']); ?>&zero_rows=<?php echo urlencode(sprintf($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>"
391 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
392 <?php
echo $titles['Drop']; ?
></a
>
395 echo "\n" . ' ' . $titles['NoDrop'];
402 if ($type == 'text' ||
$type == 'blob') {
403 echo $titles['NoPrimary'] . "\n";
407 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
408 onclick
="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,'); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
409 <?php
echo $titles['Primary']; ?
></a
>
417 if ($type == 'text' ||
$type == 'blob') {
418 echo $titles['NoUnique'] . "\n";
422 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
423 <?php
echo $titles['Unique']; ?
></a
>
431 if ($type == 'text' ||
$type == 'blob') {
432 echo $titles['NoIndex'] . "\n";
436 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
437 <?php
echo $titles['Index']; ?
></a
>
444 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
445 && (strpos(' ' . $type, 'text') ||
strpos(' ' . $type, 'varchar'))) {
448 <td align
="center" nowrap
="nowrap">
449 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex, htmlspecialchars($row['Field']))); ?>">
450 <?php
echo $titles['IdxFulltext']; ?
></a
>
456 <td align
="center" nowrap
="nowrap">
457 <?php
echo $titles['NoIdxFulltext'] . "\n"; ?
>
460 } // end if... else...
462 } // end if (! $tbl_is_view && ! $db_is_information_schema)
466 unset($field_charset);
469 echo '</tbody>' . "\n"
472 $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
475 <img
class="selectallarrow" src
="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
476 width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
477 <a href
="<?php echo $checkall_url; ?>&checkall=1"
478 onclick
="if (markAllRows('fieldsForm')) return false;">
479 <?php
echo $strCheckAll; ?
></a
>
481 <a href
="<?php echo $checkall_url; ?>"
482 onclick
="if (unMarkAllRows('fieldsForm')) return false;">
483 <?php
echo $strUncheckAll; ?
></a
>
485 <i
><?php
echo $strWithChecked; ?
></i
>
488 if ($cfg['PropertiesIconic']) {
489 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
491 echo '<input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";
493 if (! $tbl_is_view && ! $db_is_information_schema) {
494 if ($cfg['PropertiesIconic']) {
495 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
496 // Drop button if there is at least two fields
497 if ($fields_cnt > 1) {
498 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
500 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
501 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
502 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
503 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
504 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
507 // Drop button if there is at least two fields
508 if ($fields_cnt > 1) {
509 echo '<i>' . $strOr . '</i>' . "\n"
510 . '<input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n";
512 echo '<i>' . $strOr . '</i>' . "\n"
513 . '<input type="submit" name="submit_mult" value="' . $strPrimary . '" title="' . $strPrimary . '" />' . "\n";
514 echo '<i>' . $strOr . '</i>' . "\n"
515 . '<input type="submit" name="submit_mult" value="' . $strIndex . '" title="' . $strIndex . '" />' . "\n";
516 echo '<i>' . $strOr . '</i>' . "\n"
517 . '<input type="submit" name="submit_mult" value="' . $strUnique . '" title="' . $strUnique . '" />' . "\n";
518 if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
519 echo '<i>' . $strOr . '</i>' . "\n"
520 . '<input type="submit" name="submit_mult" value="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' . "\n";
533 <a href
="tbl_printview.php?<?php echo $url_query; ?>"><?php
534 if ($cfg['PropertiesIconic']) {
535 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
541 if (! $tbl_is_view && ! $db_is_information_schema) {
543 // if internal relations are available, or the table type is INNODB
544 // ($tbl_type comes from libraries/tbl_properties_table_info.inc.php)
545 if ($cfgRelation['relwork'] ||
$tbl_type=="INNODB") {
547 <a href
="tbl_relation.php?<?php echo $url_query; ?>"><?php
548 if ($cfg['PropertiesIconic']) {
549 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
551 echo $strRelationView;
556 <a href
="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
557 if ($cfg['PropertiesIconic']) {
558 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
560 echo $strStructPropose;
562 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
564 <form method
="post" action
="tbl_addfield.php"
565 onsubmit
="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
567 echo PMA_generate_common_hidden_inputs($db, $table);
568 if ($cfg['PropertiesIconic']) {
569 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
571 echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
573 <input type
="radio" name
="field_where" id
="radio_field_where_last" value
="last" checked
="checked" /><label
for="radio_field_where_last"><?php
echo $strAtEndOfTable; ?
></label
>
574 <input type
="radio" name
="field_where" id
="radio_field_where_first" value
="first" /><label
for="radio_field_where_first"><?php
echo $strAtBeginningOfTable; ?
></label
>
575 <input type
="radio" name
="field_where" id
="radio_field_where_after" value
="after" /><?php
576 $fieldOptions = '</label><select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
577 foreach ($aryFields as $fieldname) {
578 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
581 $fieldOptions .= '</select><label for="radio_field_where_after">';
582 echo str_replace('<label for="radio_field_where_after"></label>', '', '<label for="radio_field_where_after">' . sprintf($strAfter, $fieldOptions) . '</label>') . "\n";
584 <input type
="submit" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
591 * If there are more than 20 rows, displays browse/select/insert/empty/drop
594 if ($fields_cnt > 20) {
595 require './libraries/tbl_properties_links.inc.php';
596 } // end if ($fields_cnt > 20)
602 echo '<div id="tablestatistics">' . "\n";
603 if (! $tbl_is_view && ! $db_is_information_schema) {
604 define('PMA_IDX_INCLUDED', 1);
605 require './tbl_indexes.php';
609 * Displays Space usage and row statistics
611 // BEGIN - Calc Table Space - staybyte - 9 June 2001
612 // loic1, 22 feb. 2002: updated with patch from
613 // Joshua Nye <josh at boxcarmedia.com> to get valid
614 // statistics whatever is the table type
615 if ($cfg['ShowStats']) {
617 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
618 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
624 if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
627 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length']);
628 if ($mergetable == false) {
629 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length']);
631 if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
632 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free']);
633 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length'] - $showtable['Data_free']);
635 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length']);
637 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] +
$showtable['Index_length']);
638 if ($table_info_num_rows > 0) {
639 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] +
$showtable['Index_length']) / $showtable['Rows'], 6, 1);
646 <a name
="showusage"></a
>
647 <?php
if (! $tbl_is_view && ! $db_is_information_schema) { ?
>
648 <table id
="tablespaceusage" class="data">
649 <caption
class="tblHeaders"><?php
echo $strSpaceUsage; ?
></caption
>
652 <th
><?php
echo $strType; ?
></th
>
653 <th colspan
="2"><?php
echo $strUsage; ?
></th
>
657 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
658 <th
class="name"><?php
echo $strData; ?
></th
>
659 <td
class="value"><?php
echo $data_size; ?
></td
>
660 <td
class="unit"><?php
echo $data_unit; ?
></td
>
663 if (isset($index_size)) {
665 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
666 <th
class="name"><?php
echo $strIndex; ?
></th
>
667 <td
class="value"><?php
echo $index_size; ?
></td
>
668 <td
class="unit"><?php
echo $index_unit; ?
></td
>
672 if (isset($free_size)) {
674 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
675 <th
class="name"><?php
echo $strOverhead; ?
></th
>
676 <td
class="value"><?php
echo $free_size; ?
></td
>
677 <td
class="unit"><?php
echo $free_unit; ?
></td
>
679 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
680 <th
class="name"><?php
echo $strEffective; ?
></th
>
681 <td
class="value"><?php
echo $effect_size; ?
></td
>
682 <td
class="unit"><?php
echo $effect_unit; ?
></td
>
686 if (isset($tot_size) && $mergetable == false) {
688 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
689 <th
class="name"><?php
echo $strTotalUC; ?
></th
>
690 <td
class="value"><?php
echo $tot_size; ?
></td
>
691 <td
class="unit"><?php
echo $tot_unit; ?
></td
>
695 // Optimize link if overhead
696 if (isset($free_size) && ($tbl_type == 'MYISAM' ||
$tbl_type == 'BDB')) {
698 <tr
class="tblFooters">
699 <td colspan
="3" align
="center">
700 <a href
="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
701 if ($cfg['PropertiesIconic']) {
702 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
704 echo $strOptimizeTable;
717 <table id
="tablerowstats" class="data">
718 <caption
class="tblHeaders"><?php
echo $strRowsStatistic; ?
></caption
>
721 <th
><?php
echo $strStatement; ?
></th
>
722 <th
><?php
echo $strValue; ?
></th
>
727 if (isset($showtable['Row_format'])) {
729 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
730 <th
class="name"><?php
echo $strFormat; ?
></th
>
731 <td
class="value"><?php
732 if ($showtable['Row_format'] == 'Fixed') {
734 } elseif ($showtable['Row_format'] == 'Dynamic') {
737 echo $showtable['Row_format'];
743 if (PMA_MYSQL_INT_VERSION
>= 40100 && !empty($tbl_collation)) {
745 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
746 <th
class="name"><?php
echo $strCollation; ?
></th
>
747 <td
class="value"><?php
748 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
753 if (!$is_innodb && isset($showtable['Rows'])) {
755 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
756 <th
class="name"><?php
echo $strRows; ?
></th
>
757 <td
class="value"><?php
echo PMA_formatNumber($showtable['Rows'], 0); ?
></td
>
761 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
763 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
764 <th
class="name"><?php
echo $strRowLength; ?
> ø
;</th
>
765 <td
class="value"><?php
echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?
></td
>
769 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
771 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
772 <th
class="name"><?php
echo $strRowSize; ?
> ø
;</th
>
773 <td
class="value"><?php
echo $avg_size . ' ' . $avg_unit; ?
></td
>
777 if (isset($showtable['Auto_increment'])) {
779 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
780 <th
class="name"><?php
echo $strNext; ?
> Autoindex
</th
>
781 <td
class="value"><?php
echo PMA_formatNumber($showtable['Auto_increment'], 0); ?
></td
>
785 if (isset($showtable['Create_time'])) {
787 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
788 <th
class="name"><?php
echo $strStatCreateTime; ?
></th
>
789 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?
></td
>
793 if (isset($showtable['Update_time'])) {
795 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
796 <th
class="name"><?php
echo $strStatUpdateTime; ?
></th
>
797 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?
></td
>
801 if (isset($showtable['Check_time'])) {
803 <tr
class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
804 <th
class="name"><?php
echo $strStatCheckTime; ?
></th
>
805 <td
class="value"><?php
echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?
></td
>
814 // END - Calc Table Space
815 echo '<div class="clearfloat"></div>' . "\n";
816 echo '</div>' . "\n";
819 * Displays the footer
821 require_once './libraries/footer.inc.php';