3 // vim: expandtab sw=4 ts=4 sts=4:
8 require('./tbl_properties_common.php');
9 //$err_url = 'tbl_properties_operations.php' . $err_url;
10 $url_query .= '&goto=tbl_properties_operations.php&back=tbl_properties_operations.php';
14 * Gets relation settings
16 require_once('./libraries/relation.lib.php');
17 $cfgRelation = PMA_getRelationsParam();
20 * Gets available MySQL charsets and storage engines
22 require_once('./libraries/mysql_charsets.lib.php');
23 require_once('./libraries/storage_engines.lib.php');
25 // reselect current db (needed in some cases probably due to
26 // the calling of relation.lib.php)
27 PMA_DBI_select_db($db);
30 * Updates table comment, type and options if required
32 if (isset($submitcomment)) {
33 if (empty($prev_comment) ||
urldecode($prev_comment) != $comment) {
34 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
35 $result = PMA_DBI_query($sql_query);
36 $message = $strSuccess;
39 if (isset($submittype)) {
40 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $new_tbl_type;
41 $result = PMA_DBI_query($sql_query);
42 $message = $strSuccess;
44 if (isset($submitcollation)) {
45 // since something modifies $tbl_collation between the moment it is
46 // set from $_POST and this point, need to restore it
47 // (bug seen in MySQL 5.0.4)
48 $tbl_collation = $_POST['tbl_collation'];
49 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT' . PMA_generateCharsetQueryPart($tbl_collation);
50 $result = PMA_DBI_query($sql_query);
51 $message = $strSuccess;
52 unset($tbl_collation);
54 if (isset($submitoptions)) {
55 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
56 . (isset($pack_keys) ?
' pack_keys=1': ' pack_keys=0')
57 . (isset($checksum) ?
' checksum=1': ' checksum=0')
58 . (isset($delay_key_write) ?
' delay_key_write=1': ' delay_key_write=0')
59 . (!empty($auto_increment) ?
' auto_increment=' . PMA_sqlAddslashes($auto_increment) : '');
60 $result = PMA_DBI_query($sql_query);
61 $message = $strSuccess;
65 * Reordering the table has been requested by the user
67 if (isset($submitorderby) && !empty($order_field)) {
68 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
69 . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
70 if (isset($order_order) && $order_order == 'desc') {
71 $sql_query .= ' DESC';
73 $result = PMA_DBI_query($sql_query);
74 $message = $result ?
$strSuccess : $strFailed;
78 * Gets tables informations
80 require('./tbl_properties_table_info.php');
83 * Displays top menu links
85 require('./tbl_properties_links.php');
90 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
91 $result = PMA_DBI_query($local_query);
92 for ($i = 0; $row = PMA_DBI_fetch_assoc($result); $i++
) {
93 $columns[$i] = $row['Field'];
95 PMA_DBI_free_result($result);
99 <table border
="0" align
="left" cellpadding
="3" cellspacing
="0">
106 if (PMA_MYSQL_INT_VERSION
>= 32334) {
108 <!-- Order the table
-->
110 <form method
="post" action
="tbl_properties_operations.php">
111 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
113 <th
class="tblHeaders" colspan
="2" align
="left"><?php
echo $strAlterOrderBy; ?
>: 
;</th
></tr
>
115 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
116 <select name
="order_field" style
="vertical-align: middle">
119 foreach ($columns AS $junk => $fieldname) {
120 echo ' <option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
124 </select
> 
;<?php
echo $strSingly . "\n"; ?
>
125 <select name
="order_order" style
="vertical-align: middle">
126 <option value
="asc"><?php
echo $strAscending; ?
></option
>
127 <option value
="desc"><?php
echo $strDescending; ?
></option
>
130 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" align
="right">
131 <input type
="submit" name
="submitorderby" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
135 <tr
><td colspan
="2" height
="5"></td
></tr
>
140 <!-- Change table name
-->
141 <form method
="post" action
="tbl_rename.php" onsubmit
="return emptyFormElements(this, 'new_name')">
143 <th
class="tblHeaders" colspan
="2" align
="left">
144 <?php
echo $strRenameTable; ?
>: 
;
145 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
146 <input type
="hidden" name
="reload" value
="1" />
150 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
151 <input type
="text" size
="20" name
="new_name" value
="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus
="this.select()" /> 
;
153 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" align
="right">
154 <input type
="submit" value
="<?php echo $strGo; ?>" />
158 <tr
><td colspan
="2" height
="5"></td
></tr
>
160 <form method
="post" action
="tbl_move_copy.php" onsubmit
="return emptyFormElements(this, 'new_name')">
162 <th
class="tblHeaders" colspan
="2" align
="left">
163 <?php
echo $strMoveTable . "\n"; ?
>
164 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
165 <input type
="hidden" name
="reload" value
="1" />
166 <input type
="hidden" name
="what" value
="data" />
170 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" nowrap
="nowrap">
171 <select name
="target_db">
173 // The function used below is defined in "common.lib.php"
174 PMA_availableDatabases('main.php?' . PMA_generate_common_url());
175 for ($i = 0; $i < $num_dbs; $i++
) {
177 echo '<option value="' . htmlspecialchars($dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
183 <input type
="text" size
="20" name
="new_name" value
="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus
="this.select()" />
185 <td align
="<?php echo $cell_align_right; ?>" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
186 <input type
="submit" name
="submit_move" value
="<?php echo $strGo; ?>" />
190 <tr
><td colspan
="2" height
="5"></td
></tr
>
192 <form method
="post" action
="tbl_move_copy.php" onsubmit
="return emptyFormElements(this, 'new_name')">
194 <th
class="tblHeaders" colspan
="2" align
="left">
195 <?php
echo $strCopyTable . "\n"; ?
>
196 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
197 <input type
="hidden" name
="reload" value
="1" />
201 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" colspan
="2" nowrap
="nowrap">
202 <select name
="target_db">
204 for ($i = 0; $i < $num_dbs; $i++
) {
206 echo '<option value="' . htmlspecialchars($dblist[$i]) . '"';
207 if ($dblist[$i] == $db) {
208 echo ' selected="selected"';
210 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
216 <input type
="text" size
="20" name
="new_name" class="textfield" onfocus
="this.select()" />
220 <td nowrap
="nowrap" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
221 <input type
="radio" name
="what" value
="structure" id
="radio_copy_structure" style
="vertical-align: middle" /><label
for="radio_copy_structure"><?php
echo $strStrucOnly; ?
></label
> 
; 
;<br
/>
222 <input type
="radio" name
="what" value
="data" id
="radio_copy_data" checked
="checked" style
="vertical-align: middle" /><label
for="radio_copy_data"><?php
echo $strStrucData; ?
></label
> 
; 
;<br
/>
223 <input type
="radio" name
="what" value
="dataonly" id
="radio_copy_dataonly" style
="vertical-align: middle" /><label
for="radio_copy_dataonly"><?php
echo $strDataOnly; ?
></label
> 
; 
;<br
/>
225 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" style
="vertical-align: middle" /><label
for="checkbox_drop"><?php
echo $strStrucDrop; ?
></label
> 
; 
;<br
/>
226 <input type
="checkbox" name
="auto_increment" value
="1" id
="checkbox_auto_increment" style
="vertical-align: middle" /><label
for="checkbox_auto_increment"><?php
echo $strAddAutoIncrement; ?
></label
><br
/>
228 // display "Add constraints" choice only if there are
230 if (PMA_getForeigners($db, $table, '', 'innodb')) {
232 <input type
="checkbox" name
="constraints" value
="1" id
="checkbox_constraints" style
="vertical-align: middle" /><label
for="checkbox_constraints"><?php
echo $strAddConstraints; ?
></label
><br
/>
235 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') {
236 $pma_switch_to_new = 'true';
239 <input type
="checkbox" name
="switch_to_new" value
="true" id
="checkbox_switch"<?php
echo ((isset($pma_switch_to_new) && $pma_switch_to_new == 'true') ?
' checked="checked"' : ''); ?
> style
="vertical-align: middle" /><label
for="checkbox_switch"><?php
echo $strSwitchToTable; ?
></label
> 
; 
;
241 <td align
="<?php echo $cell_align_right; ?>" valign
="bottom" bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
242 <input type
="submit" name
="submit_copy" value
="<?php echo $strGo; ?>" />
246 <tr
><td colspan
="2" height
="5"></td
></tr
>
250 * Displays form controls
253 <!-- Table comments
-->
254 <form method
="post" action
="tbl_properties_operations.php">
256 <th colspan
="2" class="tblHeaders" align
="left">
258 echo PMA_generate_common_hidden_inputs($db, $table);
259 echo $strTableComments . ' ';
260 if (strstr($show_comment, '; InnoDB free') === FALSE) {
261 if (strstr($show_comment, 'InnoDB free') === FALSE) {
262 // only user entered comment
263 $comment = $show_comment;
265 // here we have just InnoDB generated part
269 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
270 $comment = preg_replace('@; InnoDB free:.*?$@' , '', $show_comment);
273 <input type
="hidden" name
="prev_comment" value
="<?php echo urlencode($comment); ?>" /> 
;
276 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
277 <input type
="text" name
="comment" maxlength
="60" size
="30" value
="<?php echo htmlspecialchars($comment); ?>" class="textfield" style
="vertical-align: middle" onfocus
="this.select()" /> 
;
279 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" align
="right">
280 <input type
="submit" name
="submitcomment" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
284 <tr
><td colspan
="2" height
="5"></td
></tr
>
287 // modify robbat2 code - staybyte - 11. June 2001
288 $result = PMA_DBI_query('SHOW VARIABLES LIKE \'have_%\';');
290 while ($tmp = PMA_DBI_fetch_assoc($result)) {
291 if (isset($tmp['Variable_name'])) {
292 switch ($tmp['Variable_name']) {
294 if ($tmp['Value'] == 'YES') {
299 if ($tmp['Value'] == 'YES') {
304 if ($tmp['Value'] == 'YES') {
309 if ($tmp['Value'] == 'YES') {
314 } // end if isset($tmp['Variable_name'])
318 PMA_DBI_free_result($result);
321 <form method
="post" action
="tbl_properties_operations.php">
323 <th colspan
="2" class="tblHeaders" align
="left">
324 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
325 <?php
echo $strTableType; ?
>: 
;
326 <?php
echo PMA_showMySQLDocu('Table_types', 'Table_types') . "\n"; ?
>
330 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
331 <?php
echo PMA_generateEnginesDropdown('new_tbl_type', NULL, FALSE, $tbl_type, 4); ?
>
333 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" align
="right">
334 <input type
="submit" name
="submittype" value
="<?php echo $strGo; ?>" />
338 <tr
><td colspan
="2" height
="5"></td
></tr
>
341 if (PMA_MYSQL_INT_VERSION
>= 40100) {
343 . '<!-- Table character set -->' . "\n"
344 . ' <form method="post" action="tbl_properties_operations.php">' . "\n"
346 . ' <th colspan="2" class="tblHeaders" align="left">' . "\n"
347 . PMA_generate_common_hidden_inputs($db, $table, 3)
348 . ' ' . $strCollation . ': ' . "\n"
352 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
353 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION
, 'tbl_collation', NULL, $tbl_collation, FALSE, 3)
355 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" align="right">' . "\n"
356 . ' <input type="submit" name="submitcollation" value="' . $strGo . '" style="vertical-align: middle" />' . "\n"
360 . ' <tr><td colspan="2" height="5"></td></tr>' . "\n";
362 // PACK_KEYS: MyISAM or ISAM
363 // DELAY_KEY_WRITE, CHECKSUM, AUTO_INCREMENT: MyISAM only
365 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'ISAM') {
367 <!-- Table options
-->
368 <form method
="post" action
="tbl_properties_operations.php">
370 <th colspan
="2" class="tblHeaders" align
="left">
371 <?php
echo $strTableOptions; ?
>: 
;
372 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
376 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
377 <input type
="checkbox" name
="pack_keys" id
="pack_keys_opt"
378 <?php
echo (isset($pack_keys) && $pack_keys == 1) ?
' checked="checked"' : ''; ?
> style
="vertical-align: middle" /><label
for="pack_keys_opt">pack_keys
</label
><br
/>
380 if ($tbl_type == 'MYISAM') {
382 <input type
="checkbox" name
="checksum" id
="checksum_opt"
383 <?php
echo (isset($checksum) && $checksum == 1) ?
' checked="checked"' : ''; ?
> style
="vertical-align: middle" /><label
for="checksum_opt">checksum
</label
><br
/>
385 <input type
="checkbox" name
="delay_key_write" id
="delay_key_write_opt"
386 <?php
echo (isset($delay_key_write) && $delay_key_write == 1) ?
' checked="checked"' : ''; ?
> style
="vertical-align: middle" /><label
for="delay_key_write_opt">delay_key_write
</label
><br
/>
388 <input type
="text" name
="auto_increment" id
="auto_increment_opt" class="textfield"
389 <?php
echo (isset($auto_increment) && !empty($auto_increment) ?
' value="' . $auto_increment . '"' : ''); ?
> style
="width: 30px; vertical-align: middle" /> 
;<label
for="auto_increment_opt">auto_increment
</label
>
394 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" align
="right" valign
="bottom">
395 <input type
="submit" name
="submitoptions" value
="<?php echo $strGo; ?>" />
400 } // end if (MYISAM or ISAM)
403 <img src
="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width
="25" height
="1" border
="0" align
="left" />
405 <table border
="0" cellpadding
="3" cellspacing
="0">
407 <th
class="tblHeaders" colspan
="2" align
="left">
408 <?php
echo $strTableMaintenance; ?
>
412 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BERKELEYDB' ||
$tbl_type == 'INNODB') {
414 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'INNODB') {
417 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
418 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
419 <?php
echo $strCheckTable; ?
></a
> 
;
421 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
422 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?
>
428 if ($tbl_type == 'INNODB') {
431 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
432 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' TYPE=InnoDB'); ?>">
433 <?php
echo $strDefragment; ?
></a
> 
;
435 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
436 <?php
echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting') . "\n"; ?
>
442 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BERKELEYDB') {
445 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
446 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
447 <?php
echo $strAnalyzeTable; ?
></a
> 
;
449 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
450 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?
>
456 if ($tbl_type == 'MYISAM') {
459 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
460 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
461 <?php
echo $strRepairTable; ?
></a
> 
;
463 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
464 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?
>
470 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BERKELEYDB') {
473 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
474 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
475 <?php
echo $strOptimizeTable; ?
></a
> 
;
477 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
478 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?
>
486 } // end MYISAM or BERKELEYDB case
490 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
491 <a href
="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('FLUSH TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenFlushed, htmlspecialchars($table))); if ($cfg['ShowTooltip']) echo '&reload=1'; ?>">
492 <?php
echo $strFlushTable; ?
></a
> 
;
494 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>">
495 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?
>
500 // Referential integrity check
501 // The Referential integrity check was intended for the non-InnoDB
502 // tables for which the relations are defined in pmadb
503 // so I assume that if the current table is InnoDB, I don't display
504 // this choice (InnoDB maintains integrity by itself)
506 if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
508 // we need this PMA_DBI_select_db if the user has access to more than one db
509 // and $db is not the last of the list, because PMA_availableDatabases()
510 // has made a PMA_DBI_select_db() on the last one
511 PMA_DBI_select_db($db);
512 $foreign = PMA_getForeigners($db, $table);
516 <!-- Referential integrity check
-->
518 <td bgcolor
="<?php echo $cfg['BgcolorOne']; ?>" colspan
="2">
519 <?php
echo $strReferentialIntegrity; ?
><br
/>
522 foreach ($foreign AS $master => $arr) {
523 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
524 . PMA_backquote($table) . ' LEFT JOIN '
525 . PMA_backquote($arr['foreign_table']);
526 if ($arr['foreign_table'] == $table) {
527 $foreign_table = $table . '1';
528 $join_query .= ' AS ' . PMA_backquote($foreign_table);
530 $foreign_table = $arr['foreign_table'];
532 $join_query .= ' ON '
533 . PMA_backquote($table) . '.' . PMA_backquote($master)
534 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
536 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
538 . PMA_backquote($table) . '.' . PMA_backquote($master)
541 . '<a href="sql.php?' . $url_query
543 . urlencode($join_query)
544 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
545 . '</a><br />' . "\n";
546 unset($foreign_table);
553 } // end if ($result)
556 } // end if (!empty($cfg['Server']['relation']))
562 * Displays the footer
565 require_once('./footer.inc.php');