display message when search returns zero rows
[phpmyadmin/dkf.git] / tbl_operations.php
blobd5fd6db31663a49b00e7614dcbf7694f753258d7
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
11 require_once './libraries/common.inc.php';
13 $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
15 /**
16 * Runs common work
18 require './libraries/tbl_common.php';
19 $url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php';
20 $url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
22 /**
23 * Gets relation settings
25 $cfgRelation = PMA_getRelationsParam();
27 /**
28 * Gets available MySQL charsets and storage engines
30 require_once './libraries/mysql_charsets.lib.php';
31 require_once './libraries/StorageEngine.class.php';
33 /**
34 * Class for partition management
36 require_once './libraries/Partition.class.php';
38 // reselect current db (needed in some cases probably due to
39 // the calling of relation.lib.php)
40 PMA_DBI_select_db($GLOBALS['db']);
42 /**
43 * Gets tables informations
46 require './libraries/tbl_info.inc.php';
48 // define some globals here, for improved syntax in the conditionals
49 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
50 // set initial value of these globals, based on the current table engine
51 PMA_set_global_variables_for_engine($tbl_type);
53 if ($is_maria) {
54 // the value for transactional can be implicit
55 // (no create option found, in this case it means 1)
56 // or explicit (option found with a value of 0 or 1)
57 // ($transactional may have been set by libraries/tbl_info.inc.php,
58 // from the $create_options)
59 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
60 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
63 $reread_info = false;
64 $table_alters = array();
66 /**
67 * Updates table comment, type and options if required
69 if (isset($_REQUEST['submitoptions'])) {
70 $_message = '';
71 $warning_messages = array();
73 if (isset($_REQUEST['new_name'])) {
74 if ($pma_table->rename($_REQUEST['new_name'])) {
75 $_message .= $pma_table->getLastMessage();
76 $result = true;
77 $GLOBALS['table'] = $pma_table->getName();
78 $reread_info = true;
79 $reload = true;
80 } else {
81 $_message .= $pma_table->getLastError();
82 $result = false;
85 if (isset($_REQUEST['comment'])
86 && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']) {
87 $table_alters[] = 'COMMENT = \'' . PMA_sqlAddslashes($_REQUEST['comment']) . '\'';
89 if (! empty($_REQUEST['new_tbl_type'])
90 && strtolower($_REQUEST['new_tbl_type']) !== strtolower($tbl_type)) {
91 $table_alters[] = 'ENGINE = ' . $_REQUEST['new_tbl_type'];
92 $tbl_type = $_REQUEST['new_tbl_type'];
93 // reset the globals for the new engine
94 PMA_set_global_variables_for_engine($tbl_type);
95 if ($is_maria) {
96 $transactional = (isset($transactional) && $transactional == '0') ? '0' : '1';
97 $page_checksum = (isset($page_checksum)) ? $page_checksum : '';
101 if (! empty($_REQUEST['tbl_collation'])
102 && $_REQUEST['tbl_collation'] !== $tbl_collation) {
103 $table_alters[] = 'DEFAULT ' . PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
106 if (($is_myisam_or_maria || $is_isam)
107 && isset($_REQUEST['new_pack_keys'])
108 && $_REQUEST['new_pack_keys'] != (string)$pack_keys) {
109 $table_alters[] = 'pack_keys = ' . $_REQUEST['new_pack_keys'];
112 $checksum = empty($checksum) ? '0' : '1';
113 $_REQUEST['new_checksum'] = empty($_REQUEST['new_checksum']) ? '0' : '1';
114 if ($is_myisam_or_maria
115 && $_REQUEST['new_checksum'] !== $checksum) {
116 $table_alters[] = 'checksum = ' . $_REQUEST['new_checksum'];
119 $_REQUEST['new_transactional'] = empty($_REQUEST['new_transactional']) ? '0' : '1';
120 if ($is_maria
121 && $_REQUEST['new_transactional'] !== $transactional) {
122 $table_alters[] = 'TRANSACTIONAL = ' . $_REQUEST['new_transactional'];
125 $_REQUEST['new_page_checksum'] = empty($_REQUEST['new_page_checksum']) ? '0' : '1';
126 if ($is_maria
127 && $_REQUEST['new_page_checksum'] !== $page_checksum) {
128 $table_alters[] = 'PAGE_CHECKSUM = ' . $_REQUEST['new_page_checksum'];
131 $delay_key_write = empty($delay_key_write) ? '0' : '1';
132 $_REQUEST['new_delay_key_write'] = empty($_REQUEST['new_delay_key_write']) ? '0' : '1';
133 if ($is_myisam_or_maria
134 && $_REQUEST['new_delay_key_write'] !== $delay_key_write) {
135 $table_alters[] = 'delay_key_write = ' . $_REQUEST['new_delay_key_write'];
138 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
139 && ! empty($_REQUEST['new_auto_increment'])
140 && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment)) {
141 $table_alters[] = 'auto_increment = ' . PMA_sqlAddslashes($_REQUEST['new_auto_increment']);
144 if (($is_myisam_or_maria || $is_innodb || $is_pbxt)
145 && ! empty($_REQUEST['new_row_format'])
146 && (! isset($row_format) || strtolower($_REQUEST['new_row_format']) !== strtolower($row_format))) {
147 $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddslashes($_REQUEST['new_row_format']);
150 if (count($table_alters) > 0) {
151 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']);
152 $sql_query .= "\r\n" . implode("\r\n", $table_alters);
153 $result .= PMA_DBI_query($sql_query) ? true : false;
154 $reread_info = true;
155 unset($table_alters);
156 foreach (PMA_DBI_get_warnings() as $warning) {
157 // In MariaDB 5.1.44, when altering a table from Maria to MyISAM
158 // and if TRANSACTIONAL was set, the system reports an error;
159 // I discussed with a Maria developer and he agrees that this
160 // should not be reported with a Level of Error, so here
161 // I just ignore it. But there are other 1478 messages
162 // that it's better to show.
163 if (! ($_REQUEST['new_tbl_type'] == 'MyISAM' && $warning['Code'] == '1478' && $warning['Level'] == 'Error')) {
164 $warning_messages[] = $warning['Level'] . ': #' . $warning['Code']
165 . ' ' . $warning['Message'];
171 * Reordering the table has been requested by the user
173 if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) {
174 $sql_query = '
175 ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . '
176 ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field']));
177 if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') {
178 $sql_query .= ' DESC';
180 $result = PMA_DBI_query($sql_query);
181 } // end if
184 * A partition operation has been requested by the user
186 if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) {
187 $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'];
188 $result = PMA_DBI_query($sql_query);
189 } // end if
191 if ($reread_info) {
192 // to avoid showing the old value (for example the AUTO_INCREMENT) after
193 // a change, clear the cache
194 PMA_Table::$cache = array();
195 $page_checksum = $checksum = $delay_key_write = 0;
196 require './libraries/tbl_info.inc.php';
198 unset($reread_info);
201 * Displays top menu links
203 require_once './libraries/tbl_links.inc.php';
205 if (isset($result) && empty($message_to_show)) {
206 // set to success by default, because result set could be empty
207 // (for example, a table rename)
208 $_type = 'success';
209 if (empty($_message)) {
210 $_message = $result ? __('Your SQL query has been executed successfully') : __('Error');
211 // $result should exist, regardless of $_message
212 $_type = $result ? 'success' : 'error';
214 if (! empty($warning_messages)) {
215 $_message = new PMA_Message;
216 $_message->addMessages($warning_messages);
217 $_message->isWarning(true);
218 unset($warning_messages);
220 PMA_showMessage($_message, $sql_query, $_type);
221 unset($_message, $_type);
224 $url_params['goto'] = 'tbl_operations.php';
225 $url_params['back'] = 'tbl_operations.php';
228 * Get columns names
230 $local_query = '
231 SHOW COLUMNS
232 FROM ' . PMA_backquote($GLOBALS['table']) . '
233 FROM ' . PMA_backquote($GLOBALS['db']);
234 $columns = PMA_DBI_fetch_result($local_query, null, 'Field');
235 unset($local_query);
238 * Displays the page
241 <!-- Order the table -->
242 <div id="div_table_order">
243 <form method="post" action="tbl_operations.php">
244 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
245 <fieldset id="fieldset_table_order">
246 <legend><?php echo __('Alter table order by'); ?></legend>
247 <select name="order_field">
248 <?php
249 foreach ($columns as $fieldname) {
250 echo ' <option value="' . htmlspecialchars($fieldname) . '">'
251 . htmlspecialchars($fieldname) . '</option>' . "\n";
253 unset($columns);
255 </select> <?php echo __('(singly)'); ?>
256 <select name="order_order">
257 <option value="asc"><?php echo __('Ascending'); ?></option>
258 <option value="desc"><?php echo __('Descending'); ?></option>
259 </select>
260 </fieldset>
261 <fieldset class="tblFooters">
262 <input type="submit" name="submitorderby" value="<?php echo __('Go'); ?>" />
263 </fieldset>
264 </form>
265 </div>
267 <!-- Move table -->
268 <div id="div_table_rename">
269 <form method="post" action="tbl_move_copy.php"
270 onsubmit="return emptyFormElements(this, 'new_name')">
271 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
272 <input type="hidden" name="reload" value="1" />
273 <input type="hidden" name="what" value="data" />
274 <fieldset id="fieldset_table_rename">
275 <legend><?php echo __('Move table to (database<b>.</b>table):'); ?></legend>
276 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
278 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
279 <?php
280 } else {
282 <select name="target_db">
283 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
284 </select>
285 <?php
286 } // end if
288 &nbsp;<strong>.</strong>&nbsp;
289 <input type="text" size="20" name="new_name" onfocus="this.select()"
290 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" /><br />
291 <?php
292 // starting with MySQL 5.0.24, SHOW CREATE TABLE includes the AUTO_INCREMENT
293 // next value but users can decide if they want it or not for the operation
295 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_mv" checked="checked" />
296 <label for="checkbox_auto_increment_mv"><?php echo __('Add AUTO_INCREMENT value'); ?></label><br />
297 </fieldset>
298 <fieldset class="tblFooters">
299 <input type="submit" name="submit_move" value="<?php echo __('Go'); ?>" />
300 </fieldset>
301 </form>
302 </div>
304 <?php
305 if (strstr($show_comment, '; InnoDB free') === false) {
306 if (strstr($show_comment, 'InnoDB free') === false) {
307 // only user entered comment
308 $comment = $show_comment;
309 } else {
310 // here we have just InnoDB generated part
311 $comment = '';
313 } else {
314 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
315 $comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
318 // PACK_KEYS: MyISAM or ISAM
319 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
320 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3, PBXT
322 // Here should be version check for InnoDB, however it is supported
323 // in >5.0.4, >4.1.12 and >4.0.11, so I decided not to
324 // check for version
327 <!-- Table options -->
328 <div id="div_table_options">
329 <form method="post" action="tbl_operations.php">
330 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
331 <input type="hidden" name="reload" value="1" />
332 <fieldset>
333 <legend><?php echo __('Table options'); ?></legend>
335 <table>
336 <!-- Change table name -->
337 <tr><td><?php echo __('Rename table to'); ?></td>
338 <td><input type="text" size="20" name="new_name" onfocus="this.select()"
339 value="<?php echo htmlspecialchars($GLOBALS['table']); ?>" />
340 </td>
341 </tr>
343 <!-- Table comments -->
344 <tr><td><?php echo __('Table comments'); ?></td>
345 <td><input type="text" name="comment" maxlength="60" size="30"
346 value="<?php echo htmlspecialchars($comment); ?>" onfocus="this.select()" />
347 <input type="hidden" name="prev_comment" value="<?php echo htmlspecialchars($comment); ?>" />
348 </td>
349 </tr>
351 <!-- Storage engine -->
352 <tr><td><?php echo __('Storage Engine'); ?>
353 <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
354 </td>
355 <td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_type', null, $tbl_type); ?>
356 </td>
357 </tr>
359 <!-- Table character set -->
360 <tr><td><?php echo __('Collation'); ?></td>
361 <td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
362 'tbl_collation', null, $tbl_collation, false, 3); ?>
363 </td>
364 </tr>
365 <?php
366 if ($is_myisam_or_maria || $is_isam) {
368 <tr>
369 <td><label for="new_pack_keys">PACK_KEYS</label></td>
370 <td><select name="new_pack_keys" id="new_pack_keys">
371 <option value="DEFAULT"
372 <?php if ($pack_keys == 'DEFAULT') echo 'selected="selected"'; ?>
373 >DEFAULT</option>
374 <option value="0"
375 <?php if ($pack_keys == '0') echo 'selected="selected"'; ?>
376 >0</option>
377 <option value="1"
378 <?php if ($pack_keys == '1') echo 'selected="selected"'; ?>
379 >1</option>
380 </select>
381 </td>
382 </tr>
383 <?php
384 } // end if (MYISAM|ISAM)
386 if ($is_myisam_or_maria) {
388 <tr><td><label for="new_checksum">CHECKSUM</label></td>
389 <td><input type="checkbox" name="new_checksum" id="new_checksum"
390 value="1"
391 <?php echo (isset($checksum) && $checksum == 1)
392 ? ' checked="checked"'
393 : ''; ?> />
394 </td>
395 </tr>
397 <tr><td><label for="new_delay_key_write">DELAY_KEY_WRITE</label></td>
398 <td><input type="checkbox" name="new_delay_key_write" id="new_delay_key_write"
399 value="1"
400 <?php echo (isset($delay_key_write) && $delay_key_write == 1)
401 ? ' checked="checked"'
402 : ''; ?> />
403 </td>
404 </tr>
406 <?php
407 } // end if (MYISAM)
409 if ($is_maria) {
411 <tr><td><label for="new_transactional">TRANSACTIONAL</label></td>
412 <td><input type="checkbox" name="new_transactional" id="new_transactional"
413 value="1"
414 <?php echo (isset($transactional) && $transactional == 1)
415 ? ' checked="checked"'
416 : ''; ?> />
417 </td>
418 </tr>
420 <tr><td><label for="new_page_checksum">PAGE_CHECKSUM</label></td>
421 <td><input type="checkbox" name="new_page_checksum" id="new_page_checksum"
422 value="1"
423 <?php echo (isset($page_checksum) && $page_checksum == 1)
424 ? ' checked="checked"'
425 : ''; ?> />
426 </td>
427 </tr>
429 <?php
430 } // end if (MARIA)
432 if (isset($auto_increment) && strlen($auto_increment) > 0
433 && ($is_myisam_or_maria || $is_innodb || $is_pbxt)) {
435 <tr><td><label for="auto_increment_opt">AUTO_INCREMENT</label></td>
436 <td><input type="text" name="new_auto_increment" id="auto_increment_opt"
437 value="<?php echo $auto_increment; ?>" /></td>
438 </tr>
439 <?php
440 } // end if (MYISAM|INNODB)
442 // the outer array is for engines, the inner array contains the dropdown
443 // option values as keys then the dropdown option labels
445 $possible_row_formats = array(
446 'MARIA' => array(
447 'FIXED' => 'FIXED',
448 'DYNAMIC' => 'DYNAMIC',
449 'PAGE' => 'PAGE'
451 'MYISAM' => array(
452 'FIXED' => 'FIXED',
453 'DYNAMIC' => 'DYNAMIC'
455 'PBXT' => array(
456 'FIXED' => 'FIXED',
457 'DYNAMIC' => 'DYNAMIC'
459 'INNODB' => array(
460 'COMPACT' => 'COMPACT',
461 'REDUNDANT' => 'REDUNDANT')
464 $innodb_engine_plugin = PMA_StorageEngine::getEngine('innodb');
465 $innodb_plugin_version = $innodb_engine_plugin->getInnodbPluginVersion();
466 if (!empty($innodb_plugin_version)) {
467 $innodb_file_format = $innodb_engine_plugin->getInnodbFileFormat();
468 } else {
469 $innodb_file_format = '';
471 if ('Barracuda' == $innodb_file_format && $innodb_engine_plugin->supportsFilePerTable()) {
472 $possible_row_formats['INNODB']['DYNAMIC'] = 'DYNAMIC';
473 $possible_row_formats['INNODB']['COMPRESSED'] = 'COMPRESSED';
475 unset($innodb_engine_plugin, $innodb_plugin_version, $innodb_file_format);
477 // for MYISAM there is also COMPRESSED but it can be set only by the
478 // myisampack utility, so don't offer here the choice because if we
479 // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
480 // does not return a warning
481 // (if the table was compressed, it can be seen on the Structure page)
483 if (isset($possible_row_formats[$tbl_type])) {
484 $current_row_format = strtoupper($showtable['Row_format']);
485 echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
486 echo '<td>';
487 echo PMA_generate_html_dropdown('new_row_format', $possible_row_formats[$tbl_type], $current_row_format, 'new_row_format');
488 unset($possible_row_formats, $current_row_format);
489 echo '</td>';
490 echo '</tr>';
493 </table>
494 </fieldset>
495 <fieldset class="tblFooters">
496 <input type="submit" name="submitoptions" value="<?php echo __('Go'); ?>" />
497 </fieldset>
498 </form>
499 </div>
501 <!-- Copy table -->
502 <div id="div_table_copy">
503 <form method="post" action="tbl_move_copy.php"
504 onsubmit="return emptyFormElements(this, 'new_name')">
505 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
506 <input type="hidden" name="reload" value="1" />
507 <fieldset>
508 <legend><?php echo __('Copy table to (database<b>.</b>table):'); ?></legend>
509 <?php if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) {
511 <input type="text" maxlength="100" size="30" name="target_db" value="<?php echo htmlspecialchars($GLOBALS['db']); ?>"/>
512 <?php
513 } else {
515 <select name="target_db">
516 <?php echo $GLOBALS['pma']->databases->getHtmlOptions(true, false); ?>
517 </select>
518 <?php
519 } // end if
521 &nbsp;<strong>.</strong>&nbsp;
522 <input type="text" size="20" name="new_name" onfocus="this.select()" value="<?php echo htmlspecialchars($GLOBALS['table']); ?>"/><br />
523 <?php
524 $choices = array(
525 'structure' => __('Structure only'),
526 'data' => __('Structure and data'),
527 'dataonly' => __('Data only'));
528 PMA_display_html_radio('what', $choices, 'data', true);
529 unset($choices);
532 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" />
533 <label for="checkbox_drop"><?php echo sprintf(__('Add %s'), 'DROP TABLE'); ?></label><br />
534 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment_cp" />
535 <label for="checkbox_auto_increment_cp"><?php echo __('Add AUTO_INCREMENT value'); ?></label><br />
536 <?php
537 // display "Add constraints" choice only if there are
538 // foreign keys
539 if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) {
541 <input type="checkbox" name="add_constraints" value="1" id="checkbox_constraints" />
542 <label for="checkbox_constraints"><?php echo __('Add constraints'); ?></label><br />
543 <?php
544 } // endif
545 if (isset($_COOKIE['pma_switch_to_new'])
546 && $_COOKIE['pma_switch_to_new'] == 'true') {
547 $pma_switch_to_new = 'true';
550 <input type="checkbox" name="switch_to_new" value="true"
551 id="checkbox_switch"<?php echo
552 isset($pma_switch_to_new) && $pma_switch_to_new == 'true'
553 ? ' checked="checked"'
554 : ''; ?> />
555 <label for="checkbox_switch"><?php echo __('Switch to copied table'); ?></label>
556 </fieldset>
557 <fieldset class="tblFooters">
558 <input type="submit" name="submit_copy" value="<?php echo __('Go'); ?>" />
559 </fieldset>
560 </form>
561 </div>
563 <br class="clearfloat"/>
565 <div id="div_table_maintenance">
566 <fieldset>
567 <legend><?php echo __('Table maintenance'); ?></legend>
569 <ul>
570 <?php
571 // Note: BERKELEY (BDB) is no longer supported, starting with MySQL 5.1
572 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
573 if ($is_myisam_or_maria || $is_innodb) {
574 $this_url_params = array_merge($url_params,
575 array('sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table'])));
577 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
578 <?php echo __('Check table'); ?></a>
579 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
580 </li>
581 <?php
583 if ($is_innodb) {
584 $this_url_params = array_merge($url_params,
585 array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB'));
587 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
588 <?php echo __('Defragment table'); ?></a>
589 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
590 </li>
591 <?php
593 if ($is_myisam_or_maria || $is_berkeleydb) {
594 $this_url_params = array_merge($url_params,
595 array('sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table'])));
597 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
598 <?php echo __('Analyze table'); ?></a>
599 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
600 </li>
601 <?php
603 if ($is_myisam_or_maria) {
604 $this_url_params = array_merge($url_params,
605 array('sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])));
607 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
608 <?php echo __('Repair table'); ?></a>
609 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
610 </li>
611 <?php
613 if ($is_myisam_or_maria || $is_innodb || $is_berkeleydb) {
614 $this_url_params = array_merge($url_params,
615 array('sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table'])));
617 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
618 <?php echo __('Optimize table'); ?></a>
619 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
620 </li>
621 <?php
623 } // end MYISAM or BERKELEYDB case
624 $this_url_params = array_merge($url_params,
625 array(
626 'sql_query' => 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']),
627 'message_to_show' => sprintf(__('Table %s has been flushed'),
628 htmlspecialchars($GLOBALS['table'])),
629 'reload' => 1,
632 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
633 <?php echo __('Flush the table (FLUSH)'); ?></a>
634 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
635 </li>
636 </ul>
637 </fieldset>
638 </div>
639 <?php if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?>
640 <div id="div_table_removal">
641 <fieldset class="caution">
642 <legend><?php echo __('Delete data or table'); ?></legend>
644 <ul>
645 <?php
646 if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
647 $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
648 $this_url_params = array_merge($url_params,
649 array(
650 'sql_query' => $this_sql_query,
651 'goto' => 'tbl_structure.php',
652 'reload' => '1',
653 'message_to_show' => sprintf(__('Table %s has been emptied'), htmlspecialchars($table)),
656 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
657 <?php echo __('Empty the table (TRUNCATE)'); ?></a>
658 <?php echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
659 </li>
660 <?php
662 if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
663 $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
664 $this_url_params = array_merge($url_params,
665 array(
666 'sql_query' => $this_sql_query,
667 'goto' => 'db_operations.php',
668 'reload' => '1',
669 'purge' => '1',
670 'message_to_show' => sprintf(($tbl_is_view ? __('View %s has been dropped') : __('Table %s has been dropped')), htmlspecialchars($table)),
671 // table name is needed to avoid running
672 // PMA_relationsCleanupDatabase() on the whole db later
673 'table' => $GLOBALS['table'],
676 <li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" onclick="return confirmLink(this, '<?php echo PMA_jsFormat($this_sql_query); ?>')">
677 <?php echo __('Delete the table (DROP)'); ?></a>
678 <?php echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
679 </li>
680 <?php
683 </ul>
684 </fieldset>
685 </div>
686 <?php
689 <?php if (PMA_Partition::havePartitioning()) {
690 $partition_names = PMA_Partition::getPartitionNames($db, $table);
691 // show the Partition maintenance section only if we detect a partition
692 if (! is_null($partition_names[0])) {
694 <div id="div_partition_maintenance">
695 <form method="post" action="tbl_operations.php">
696 <?php echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); ?>
697 <fieldset>
698 <legend><?php echo __('Partition maintenance'); ?></legend>
699 <?php
700 $html_select = '<select name="partition_name">' . "\n";
701 foreach($partition_names as $one_partition) {
702 $one_partition = htmlspecialchars($one_partition);
703 $html_select .= '<option value="' . $one_partition . '">' . $one_partition . '</option>' . "\n";
705 $html_select .= '</select>' . "\n";
706 printf(__('Partition %s'), $html_select);
707 unset($partition_names, $one_partition, $html_select);
708 $choices = array(
709 'ANALYZE' => __('Analyze'),
710 'CHECK' => __('Check'),
711 'OPTIMIZE' => __('Optimize'),
712 'REBUILD' => __('Rebuild'),
713 'REPAIR' => __('Repair'));
714 PMA_display_html_radio('partition_operation', $choices, '', false);
715 unset($choices);
716 echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance');
717 // I'm not sure of the best way to display that; this link does
718 // not depend on the Go button
719 $this_url_params = array_merge($url_params,
720 array(
721 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING'
724 <br /><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
725 <?php echo __('Remove partitioning'); ?></a>
726 </fieldset>
727 <fieldset class="tblFooters">
728 <input type="submit" name="submit_partition" value="<?php echo __('Go'); ?>" />
729 </fieldset>
730 </form>
731 </div>
732 <?php
733 } // end if
734 } // end if
736 // Referential integrity check
737 // The Referential integrity check was intended for the non-InnoDB
738 // tables for which the relations are defined in pmadb
739 // so I assume that if the current table is InnoDB, I don't display
740 // this choice (InnoDB maintains integrity by itself)
742 if ($cfgRelation['relwork'] && ! $is_innodb) {
743 PMA_DBI_select_db($GLOBALS['db']);
744 $foreign = PMA_getForeigners($GLOBALS['db'], $GLOBALS['table']);
746 if ($foreign) {
748 <!-- Referential integrity check -->
749 <div id="div_referential_integrity">
750 <fieldset>
751 <legend><?php echo __('Check referential integrity:'); ?></legend>
752 <ul>
753 <?php
754 echo "\n";
755 foreach ($foreign AS $master => $arr) {
756 $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM '
757 . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN '
758 . PMA_backquote($arr['foreign_table']);
759 if ($arr['foreign_table'] == $GLOBALS['table']) {
760 $foreign_table = $GLOBALS['table'] . '1';
761 $join_query .= ' AS ' . PMA_backquote($foreign_table);
762 } else {
763 $foreign_table = $arr['foreign_table'];
765 $join_query .= ' ON '
766 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
767 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
768 . ' WHERE '
769 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
770 . ' IS NULL AND '
771 . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master)
772 . ' IS NOT NULL';
773 $this_url_params = array_merge($url_params,
774 array('sql_query' => $join_query));
775 echo ' <li>'
776 . '<a href="sql.php'
777 . PMA_generate_common_url($this_url_params)
778 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
779 . '</a></li>' . "\n";
780 } // foreach $foreign
781 unset($foreign_table, $join_query);
783 </ul>
784 </fieldset>
785 </div>
786 <?php
787 } // end if ($foreign)
789 } // end if (!empty($cfg['Server']['relation']))
793 * Displays the footer
795 require './libraries/footer.inc.php';
798 function PMA_set_global_variables_for_engine($tbl_type)
800 global $is_myisam_or_maria, $is_innodb, $is_isam, $is_berkeleydb, $is_maria, $is_pbxt;
802 $is_myisam_or_maria = $is_isam = $is_innodb = $is_berkeleydb = $is_maria = $is_pbxt = false;
803 $upper_tbl_type = strtoupper($tbl_type);
805 //Options that apply to MYISAM usually apply to MARIA
806 $is_myisam_or_maria = ($upper_tbl_type == 'MYISAM' || $upper_tbl_type == 'MARIA');
807 $is_maria = ($upper_tbl_type == 'MARIA');
809 $is_isam = ($upper_tbl_type == 'ISAM');
810 $is_innodb = ($upper_tbl_type == 'INNODB');
811 $is_berkeleydb = ($upper_tbl_type == 'BERKELEYDB');
812 $is_pbxt = ($upper_tbl_type == 'PBXT');