Translation update done using Pootle.
[phpmyadmin/ammar_yasir.git] / tbl_structure.php
blob17c2e73d026b34c2a1a05a28036b3cfc95aace63
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', __('Add primary key'), false, true);
166 $hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Add primary key'), false, true);
167 $hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Add index'), false, true);
168 $hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Add index'), false, true);
169 $hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Add unique index'), false, true);
170 $hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Add unique index'), false, true);
171 $hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Add FULLTEXT index'), false, true);
172 $hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Add FULLTEXT index'), 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'] . '(' .
249 str_replace("','", "', '", $extracted_fieldspec['spec_in_brackets']) . ')';
251 // for the case ENUM('&#8211;','&ldquo;')
252 $type = htmlspecialchars($type);
253 if(strlen($type) > $GLOBALS['cfg']['LimitChars']) {
254 $type = '<abbr title="full text">' . substr($type, 0, $GLOBALS['cfg']['LimitChars']) . '</abbr>';
257 $type_nowrap = '';
259 $binary = 0;
260 $unsigned = 0;
261 $zerofill = 0;
262 } else {
263 $type_nowrap = ' nowrap="nowrap"';
264 // strip the "BINARY" attribute, except if we find "BINARY(" because
265 // this would be a BINARY or VARBINARY field type
266 if (!preg_match('@BINARY[\(]@i', $type)) {
267 $type = preg_replace('@BINARY@i', '', $type);
269 $type = preg_replace('@ZEROFILL@i', '', $type);
270 $type = preg_replace('@UNSIGNED@i', '', $type);
271 if (empty($type)) {
272 $type = ' ';
275 if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
276 $binary = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
277 } else {
278 $binary = false;
281 $unsigned = stristr($row['Type'], 'unsigned');
282 $zerofill = stristr($row['Type'], 'zerofill');
285 unset($field_charset);
286 if ((substr($type, 0, 4) == 'char'
287 || substr($type, 0, 7) == 'varchar'
288 || substr($type, 0, 4) == 'text'
289 || substr($type, 0, 8) == 'tinytext'
290 || substr($type, 0, 10) == 'mediumtext'
291 || substr($type, 0, 8) == 'longtext'
292 || substr($type, 0, 3) == 'set'
293 || substr($type, 0, 4) == 'enum'
294 ) && !$binary) {
295 if (strpos($type, ' character set ')) {
296 $type = substr($type, 0, strpos($type, ' character set '));
298 if (!empty($row['Collation'])) {
299 $field_charset = $row['Collation'];
300 } else {
301 $field_charset = '';
303 } else {
304 $field_charset = '';
307 // Display basic mimetype [MIME]
308 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
309 $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
310 } else {
311 $type_mime = '';
314 $attribute = ' ';
315 if ($binary) {
316 $attribute = 'BINARY';
318 if ($unsigned) {
319 $attribute = 'UNSIGNED';
321 if ($zerofill) {
322 $attribute = 'UNSIGNED ZEROFILL';
325 // MySQL 4.1.2+ TIMESTAMP options
326 // (if on_update_current_timestamp is set, then it's TRUE)
327 if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
328 $attribute = 'on update CURRENT_TIMESTAMP';
331 // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
332 // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
333 // the latter.
334 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']) {
335 $row['Null'] = '';
339 if (!isset($row['Default'])) {
340 if ($row['Null'] == 'YES') {
341 $row['Default'] = '<i>NULL</i>';
343 } else {
344 $row['Default'] = htmlspecialchars($row['Default']);
347 $field_encoded = urlencode($row['Field']);
348 $field_name = htmlspecialchars($row['Field']);
349 $displayed_field_name = $field_name;
351 // underline commented fields and display a hover-title (CSS only)
353 if (isset($comments_map[$row['Field']])) {
354 $displayed_field_name = '<span class="commented_column" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
357 if ($primary && $primary->hasColumn($field_name)) {
358 $displayed_field_name = '<u>' . $field_name . '</u>';
360 echo "\n";
362 <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
363 <td align="center">
364 <input type="checkbox" name="selected_fld[]" value="<?php echo htmlspecialchars($row['Field']); ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
365 </td>
366 <td align="right">
367 <?php echo $rownum; ?>
368 </td>
369 <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $displayed_field_name; ?></label></th>
370 <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
371 <td><?php echo (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>'); ?></td>
372 <td nowrap="nowrap" class="column_attribute"><?php echo $attribute; ?></td>
373 <td><?php echo (($row['Null'] == 'YES') ? __('Yes') : __('No')); ?></td>
374 <td nowrap="nowrap"><?php
375 if (isset($row['Default'])) {
376 if ($extracted_fieldspec['type'] == 'bit') {
377 // here, $row['Default'] contains something like b'010'
378 echo PMA_convert_bit_default_value($row['Default']);
379 } else {
380 echo $row['Default'];
383 else {
384 echo '<i>' . _pgettext('None for default','None') . '</i>';
385 } ?></td>
386 <td nowrap="nowrap"><?php echo strtoupper($row['Extra']); ?></td>
387 <td align="center" class="browse">
388 <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'])); ?>">
389 <?php echo $titles['BrowseDistinctValues']; ?></a>
390 </td>
391 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
392 <td align="center" class="edit">
393 <a href="tbl_alter.php?<?php echo $url_query; ?>&amp;field=<?php echo $field_encoded; ?>">
394 <?php echo $titles['Change']; ?></a>
395 </td>
396 <td align="center" class="drop">
397 <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;dropped_column=<?php echo urlencode($row['Field']); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
398 <?php echo $titles['Drop']; ?></a>
399 </td>
400 <td align="center" class="primary">
401 <?php
402 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || ($primary && $primary->hasColumn($field_name))) {
403 echo $titles['NoPrimary'] . "\n";
404 $primary_enabled = false;
405 } else {
406 echo "\n";
408 <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;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
409 <?php echo $titles['Primary']; ?></a>
410 <?php $primary_enabled = true;
412 echo "\n";
414 </td>
415 <td align="center" class="unique">
416 <?php
417 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type || isset($columns_with_unique_index[$field_name])) {
418 echo $titles['NoUnique'] . "\n";
419 $unique_enabled = false;
420 } else {
421 echo "\n";
423 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
424 <?php echo $titles['Unique']; ?></a>
425 <?php $unique_enabled = true;
427 echo "\n";
429 </td>
430 <td align="center" class="index">
431 <?php
432 if ($type == 'text' || $type == 'blob' || 'ARCHIVE' == $tbl_type) {
433 echo $titles['NoIndex'] . "\n";
434 $index_enabled = false;
435 } else {
436 echo "\n";
438 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
439 <?php echo $titles['Index']; ?></a>
440 <?php
441 $index_enabled = true;
443 echo "\n";
445 </td>
446 <?php
447 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')
448 // FULLTEXT is possible on TEXT, CHAR and VARCHAR
449 && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
450 echo "\n";
452 <td align="center" nowrap="nowrap" class="fulltext">
453 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
454 <?php echo $titles['IdxFulltext']; ?></a>
455 <?php $fulltext_enabled = true; ?>
456 </td>
457 <?php
458 } else {
459 echo "\n";
461 <td align="center" nowrap="nowrap" class="fulltext">
462 <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
463 <?php $fulltext_enabled = false; ?>
464 </td>
465 <?php
466 } // end if... else...
467 echo "\n";
468 } // end if (! $tbl_is_view && ! $db_is_information_schema)
470 <td class="more_opts" id="more_opts<?php echo $rownum; ?>">
471 More <img src="<?php echo $pmaThemeImage . 'more.png'; ?>" alt="show more actions" />
472 <div class="structure_actions_dropdown" id="row_<?php echo $rownum; ?>">
474 <div class="action_browse">
475 <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'])); ?>">
476 <?php echo $hidden_titles['BrowseDistinctValues']; ?>
477 </a>
478 </div>
479 <div class="action_primary">
480 <?php
481 if(isset($primary_enabled)) {
482 if($primary_enabled) { ?>
483 <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;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
484 <?php echo $hidden_titles['Primary']; ?>
485 </a>
486 <?php
487 } else {
488 echo $hidden_titles['NoPrimary'];
490 } ?>
491 </div>
492 <div class="action_unique">
493 <?php
494 if(isset($unique_enabled)) {
495 if($unique_enabled) { ?>
496 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
497 <?php echo $hidden_titles['Unique']; ?>
498 </a>
499 <?php
500 } else {
501 echo $hidden_titles['NoUnique'];
503 } ?>
504 </div>
505 <div class="action_index">
506 <?php
507 if(isset($index_enabled)) {
508 if($index_enabled) { ?>
509 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
510 <?php echo $hidden_titles['Index']; ?>
511 </a>
512 <?php
513 } else {
514 echo $hidden_titles['NoIndex'];
516 } ?>
517 </div>
518 <div class="action_fulltext">
519 <?php
520 if(isset($fulltext_enabled)) {
521 if($fulltext_enabled) { ?>
522 <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;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
523 <?php echo $hidden_titles['IdxFulltext']; ?>
524 </a>
525 <?php
526 } else {
527 echo $hidden_titles['NoIdxFulltext'];
529 } ?>
530 </div>
531 </div>
532 </td>
533 </tr>
534 <?php
535 unset($field_charset);
536 } // end while
538 echo '</tbody>' . "\n"
539 .'</table>' . "\n";
541 $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
544 <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
545 width="38" height="22" alt="<?php echo __('With selected:'); ?>" />
546 <a href="<?php echo $checkall_url; ?>&amp;checkall=1"
547 onclick="if (markAllRows('fieldsForm')) return false;">
548 <?php echo __('Check All'); ?></a>
550 <a href="<?php echo $checkall_url; ?>"
551 onclick="if (unMarkAllRows('fieldsForm')) return false;">
552 <?php echo __('Uncheck All'); ?></a>
554 <i><?php echo __('With selected:'); ?></i>
556 <?php
557 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', __('Browse'), 'b_browse.png');
559 if (! $tbl_is_view && ! $db_is_information_schema) {
560 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', __('Change'), 'b_edit.png');
561 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png');
562 if ('ARCHIVE' != $tbl_type) {
563 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', __('Primary'), 'b_primary.png');
564 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', __('Unique'), 'b_unique.png');
565 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', __('Index'), 'b_index.png');
568 if (! empty($tbl_type) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA')) {
569 PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', __('Fulltext'), 'b_ftext.png');
573 </form>
574 <hr />
576 <?php
578 * Work on the table
581 <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
582 if ($cfg['PropertiesIconic']) {
583 echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . __('Print view') . '"/>';
585 echo __('Print view');
586 ?></a>
588 <?php
589 if (! $tbl_is_view && ! $db_is_information_schema) {
591 // if internal relations are available, or foreign keys are supported
592 // ($tbl_type comes from libraries/tbl_info.inc.php)
593 if ($cfgRelation['relwork'] || PMA_foreignkey_supported($tbl_type)) {
595 <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
596 if ($cfg['PropertiesIconic']) {
597 echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . __('Relation view') . '"/>';
599 echo __('Relation view');
600 ?></a>
601 <?php
604 <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
605 if ($cfg['PropertiesIconic']) {
606 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . __('Propose table structure') . '" />';
608 echo __('Propose table structure');
609 ?></a><?php
610 echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
613 if(PMA_Tracker::isActive())
615 echo '<a href="tbl_tracking.php?' . $url_query . '">';
617 if ($cfg['PropertiesIconic'])
619 echo '<img class="icon" src="' . $pmaThemeImage . 'eye.png" width="16" height="16" alt="' . __('Track table') . '" /> ';
621 echo __('Track table') . '</a>';
625 <br />
626 <form method="post" action="tbl_addfield.php"
627 onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', __('You have to add at least one column.')); ?>', 1)">
628 <?php
629 echo PMA_generate_common_hidden_inputs($db, $table);
630 if ($cfg['PropertiesIconic']) {
631 echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . __('Add column') . '"/>';
633 echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
635 // I tried displaying the drop-down inside the label but with Firefox
636 // the drop-down was blinking
637 $fieldOptions = '<select name="after_field" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
638 foreach ($aryFields as $fieldname) {
639 $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
641 unset($aryFields);
642 $fieldOptions .= '</select>';
644 $choices = array(
645 'last' => __('At End of Table'),
646 'first' => __('At Beginning of Table'),
647 'after' => sprintf(__('After %s'), '')
649 PMA_display_html_radio('field_where', $choices, 'last', false);
650 echo $fieldOptions;
651 unset($fieldOptions, $choices);
653 <input type="submit" value="<?php echo __('Go'); ?>" />
654 </form>
655 <iframe class="IE_hack" scrolling="no"></iframe>
656 <hr />
657 <?php
661 * If there are more than 20 rows, displays browse/select/insert/empty/drop
662 * links again
664 if ($fields_cnt > 20) {
665 require './libraries/tbl_links.inc.php';
666 } // end if ($fields_cnt > 20)
669 * Displays indexes
672 if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_type) {
674 * Display indexes
676 echo PMA_Index::getView($table, $db);
678 <br />
679 <form action="./tbl_indexes.php" method="post"
680 onsubmit="return checkFormElementInRange(this, 'idx_num_fields',
681 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
682 1)">
683 <fieldset>
684 <?php
685 echo PMA_generate_common_hidden_inputs($db, $table);
686 echo sprintf(__('Create an index on &nbsp;%s&nbsp;columns'),
687 '<input type="text" size="2" name="added_fields" value="1" />');
689 <input type="submit" name="create_index" value="<?php echo __('Go'); ?>"
690 onclick="return checkFormElementInRange(this.form,
691 'idx_num_fields',
692 '<?php echo str_replace('\'', '\\\'', __('Column count has to be larger than zero.')); ?>',
693 1)" />
694 </fieldset>
695 </form>
696 <br />
697 <?php
700 PMA_generate_slider_effect('tablestatistics', __('Details...'));
703 * Displays Space usage and row statistics
705 // BEGIN - Calc Table Space
706 // Get valid statistics whatever is the table type
707 if ($cfg['ShowStats']) {
708 if (empty($showtable)) {
709 $showtable = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, true);
712 $nonisam = false;
713 $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
714 if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
715 $nonisam = true;
718 // Gets some sizes
720 $mergetable = PMA_Table::isMerge($GLOBALS['db'], $GLOBALS['table']);
722 // this is to display for example 261.2 MiB instead of 268k KiB
723 $max_digits = 5;
724 $decimals = 1;
725 list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
726 if ($mergetable == false) {
727 list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
729 // InnoDB returns a huge value in Data_free, do not use it
730 if (! $is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
731 list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
732 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
733 } else {
734 list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
736 list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
737 if ($table_info_num_rows > 0) {
738 list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
741 // Displays them
742 $odd_row = false;
745 <a name="showusage"></a>
746 <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
747 <table id="tablespaceusage" class="data">
748 <caption class="tblHeaders"><?php echo __('Space usage'); ?></caption>
749 <thead>
750 <tr>
751 <th><?php echo __('Type'); ?></th>
752 <th colspan="2"><?php echo __('Usage'); ?></th>
753 </tr>
754 </thead>
755 <tbody>
756 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
757 <th class="name"><?php echo __('Data'); ?></th>
758 <td class="value"><?php echo $data_size; ?></td>
759 <td class="unit"><?php echo $data_unit; ?></td>
760 </tr>
761 <?php
762 if (isset($index_size)) {
764 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
765 <th class="name"><?php echo __('Index'); ?></th>
766 <td class="value"><?php echo $index_size; ?></td>
767 <td class="unit"><?php echo $index_unit; ?></td>
768 </tr>
769 <?php
771 if (isset($free_size)) {
773 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
774 <th class="name"><?php echo __('Overhead'); ?></th>
775 <td class="value"><?php echo $free_size; ?></td>
776 <td class="unit"><?php echo $free_unit; ?></td>
777 </tr>
778 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
779 <th class="name"><?php echo __('Effective'); ?></th>
780 <td class="value"><?php echo $effect_size; ?></td>
781 <td class="unit"><?php echo $effect_unit; ?></td>
782 </tr>
783 <?php
785 if (isset($tot_size) && $mergetable == false) {
787 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
788 <th class="name"><?php echo __('Total'); ?></th>
789 <td class="value"><?php echo $tot_size; ?></td>
790 <td class="unit"><?php echo $tot_unit; ?></td>
791 </tr>
792 <?php
794 // Optimize link if overhead
795 if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'ARIA' || $tbl_type == 'MARIA' || $tbl_type == 'BDB')) {
797 <tr class="tblFooters">
798 <td colspan="3" align="center">
799 <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
800 if ($cfg['PropertiesIconic']) {
801 echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . __('Optimize table'). '" />';
803 echo __('Optimize table');
804 ?></a>
805 </td>
806 </tr>
807 <?php
810 </tbody>
811 </table>
812 <?php
814 $odd_row = false;
816 <table id="tablerowstats" class="data">
817 <caption class="tblHeaders"><?php echo __('Row Statistics'); ?></caption>
818 <thead>
819 <tr>
820 <th><?php echo __('Statements'); ?></th>
821 <th><?php echo __('Value'); ?></th>
822 </tr>
823 </thead>
824 <tbody>
825 <?php
826 if (isset($showtable['Row_format'])) {
828 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
829 <th class="name"><?php echo __('Format'); ?></th>
830 <td class="value"><?php
831 if ($showtable['Row_format'] == 'Fixed') {
832 echo __('static');
833 } elseif ($showtable['Row_format'] == 'Dynamic') {
834 echo __('dynamic');
835 } else {
836 echo $showtable['Row_format'];
838 ?></td>
839 </tr>
840 <?php
842 if (! empty($showtable['Create_options'])) {
844 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
845 <th class="name"><?php echo __('Options'); ?></th>
846 <td class="value"><?php
847 if ($showtable['Create_options'] == 'partitioned') {
848 echo __('partitioned');
849 } else {
850 echo $showtable['Create_options'];
852 ?></td>
853 </tr>
854 <?php
856 if (!empty($tbl_collation)) {
858 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
859 <th class="name"><?php echo __('Collation'); ?></th>
860 <td class="value"><?php
861 echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
862 ?></td>
863 </tr>
864 <?php
866 if (!$is_innodb && isset($showtable['Rows'])) {
868 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
869 <th class="name"><?php echo __('Rows'); ?></th>
870 <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
871 </tr>
872 <?php
874 if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
876 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
877 <th class="name"><?php echo __('Row length'); ?> &oslash;</th>
878 <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
879 </tr>
880 <?php
882 if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
884 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
885 <th class="name"><?php echo __(' Row size '); ?> &oslash;</th>
886 <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
887 </tr>
888 <?php
890 if (isset($showtable['Auto_increment'])) {
892 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
893 <th class="name"><?php echo __('Next'); ?> Autoindex</th>
894 <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
895 </tr>
896 <?php
898 if (isset($showtable['Create_time'])) {
900 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
901 <th class="name"><?php echo __('Creation'); ?></th>
902 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
903 </tr>
904 <?php
906 if (isset($showtable['Update_time'])) {
908 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
909 <th class="name"><?php echo __('Last update'); ?></th>
910 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
911 </tr>
912 <?php
914 if (isset($showtable['Check_time'])) {
916 <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
917 <th class="name"><?php echo __('Last check'); ?></th>
918 <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
919 </tr>
920 <?php
923 </tbody>
924 </table>
926 <!-- close slider div -->
927 </div>
929 <?php
931 // END - Calc Table Space
933 require './libraries/tbl_triggers.lib.php';
935 echo '<div class="clearfloat"></div>' . "\n";
938 * Displays the footer
940 require './libraries/footer.inc.php';