3 // vim: expandtab sw=4 ts=4 sts=4:
9 require('./tbl_properties_common.php3');
10 //$err_url = 'tbl_properties_operations.php3' . $err_url;
11 $url_query .= '&goto=tbl_properties_operations.php3&back=tbl_properties_operations.php3';
15 * Gets relation settings
17 require('./libraries/relation.lib.php3');
18 $cfgRelation = PMA_getRelationsParam();
21 * Gets available MySQL charsets
23 if (PMA_MYSQL_INT_VERSION
>= 40100 && !defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')) {
24 include('./libraries/mysql_charsets.lib.php3');
28 * Updates table comment, type and options if required
30 if (isset($submitcomment)) {
31 if (empty($prev_comment) ||
urldecode($prev_comment) != $comment) {
32 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
33 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
34 $message = $strSuccess;
37 if (isset($submittype)) {
38 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $tbl_type;
39 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
40 $message = $strSuccess;
42 if (isset($submitcharset)) {
43 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHARACTER SET = ' . $tbl_charset;
44 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
45 $message = $strSuccess;
47 if (isset($submitoptions)) {
48 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
49 . (isset($pack_keys) ?
' pack_keys=1': ' pack_keys=0')
50 . (isset($checksum) ?
' checksum=1': ' checksum=0')
51 . (isset($delay_key_write) ?
' delay_key_write=1': ' delay_key_write=0')
52 . (isset($auto_increment) ?
' auto_increment=' . PMA_sqlAddslashes($auto_increment) : '');
53 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
54 $message = $strSuccess;
57 // Displays a message if a query had been submitted
58 if (isset($message)) {
59 PMA_showMessage($message);
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 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
71 PMA_showMessage($strSuccess);
76 * Gets tables informations and displays top links
78 require('./tbl_properties_table_info.php3');
84 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
85 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url);
86 for ($i = 0; $row = PMA_mysql_fetch_array($result); $i++
) {
87 $columns[$i] = $row['Field'];
89 mysql_free_result($result);
99 if (PMA_MYSQL_INT_VERSION
>= 32334) {
101 <!-- Order the table
-->
103 <form method
="post" action
="tbl_properties_operations.php3">
104 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
105 <?php
echo $strAlterOrderBy; ?
> 
;:
106 <select name
="order_field" style
="vertical-align: middle">
110 while (list($junk, $fieldname) = each($columns)) {
111 echo ' <option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
116 <input type
="submit" name
="submitorderby" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
117  
;<?php
echo $strSingly . "\n"; ?
>
125 <!-- Change table name
-->
127 <form method
="post" action
="tbl_rename.php3"
128 onsubmit
="return emptyFormElements(this, 'new_name')">
129 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
130 <input type
="hidden" name
="reload" value
="1" />
131 <?php
echo $strRenameTable; ?
> 
;:
132 <input type
="text" size
="20" name
="new_name" value
="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus
="this.select()" /> 
;
133 <input type
="submit" value
="<?php echo $strGo; ?>" />
139 <?php
echo $strMoveTable . "\n"; ?
>
140 <form method
="post" action
="tbl_move_copy.php3"
141 onsubmit
="return emptyFormElements(this, 'new_name')">
142 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
143 <input type
="hidden" name
="reload" value
="1" />
144 <input type
="hidden" name
="what" value
="data" />
145 <table border
="0" cellspacing
="0" cellpadding
="0">
148 <select name
="target_db">
150 // The function used below is defined in "common.lib.php3"
151 PMA_availableDatabases('main.php3?' . PMA_generate_common_url());
152 for ($i = 0; $i < $num_dbs; $i++
) {
154 echo '<option value="' . htmlspecialchars($dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
160 <input type
="text" size
="20" name
="new_name" value
="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus
="this.select()" />
164 <td align
="<?php echo $cell_align_right; ?>" valign
="top">
165 <input type
="submit" name
="submit_move" value
="<?php echo $strGo; ?>" />
174 <?php
echo $strCopyTable . "\n"; ?
>
175 <form method
="post" action
="tbl_move_copy.php3"
176 onsubmit
="return emptyFormElements(this, 'new_name')">
177 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
178 <input type
="hidden" name
="reload" value
="1" />
179 <table border
="0" cellspacing
="0" cellpadding
="0">
182 <select name
="target_db">
184 for ($i = 0; $i < $num_dbs; $i++
) {
186 echo '<option value="' . htmlspecialchars($dblist[$i]) . '"';
187 if ($dblist[$i] == $db) {
188 echo ' selected="selected"';
190 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
196 <input type
="text" size
="20" name
="new_name" class="textfield" onfocus
="this.select()" />
201 <input type
="radio" name
="what" value
="structure" id
="radio_copy_structure" checked
="checked" />
202 <label
for="radio_copy_structure"><?php
echo $strStrucOnly; ?
></label
> 
; 
;<br
/>
203 <input type
="radio" name
="what" value
="data" id
="radio_copy_data" />
204 <label
for="radio_copy_data"><?php
echo $strStrucData; ?
></label
> 
; 
;<br
/>
205 <input type
="radio" name
="what" value
="dataonly" id
="radio_copy_dataonly" />
206 <label
for="radio_copy_dataonly"><?php
echo $strDataOnly; ?
></label
> 
; 
;<br
/>
207 <input type
="checkbox" name
="drop_if_exists" value
="true" id
="checkbox_drop" />
208 <label
for="checkbox_drop"><?php
echo $strStrucDrop; ?
></label
> 
; 
;<br
/>
209 <input type
="checkbox" name
="auto_increment" value
="1" id
="checkbox_auto_increment" />
210 <label
for="checkbox_auto_increment"><?php
echo $strAddAutoIncrement; ?
></label
><br
/>
212 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') {
213 $pma_switch_to_new = 'true';
214 } elseif (isset($HTTP_COOKIE_VARS) && isset($HTTP_COOKIE_VARS['pma_switch_to_new']) && $HTTP_COOKIE_VARS['pma_switch_to_new'] == 'true') {
215 $pma_switch_to_new = 'true';
218 <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"' : ''); ?
>/>
219 <label
for="checkbox_switch"><?php
echo $strSwitchToTable; ?
></label
> 
; 
;
221 <td align
="<?php echo $cell_align_right; ?>" valign
="top">
222 <input type
="submit" name
="submit_copy" value
="<?php echo $strGo; ?>" />
229 <!-- Table maintenance
-->
231 <?php
echo $strTableMaintenance; ?
>
234 if (PMA_MYSQL_INT_VERSION
>= 32322) {
235 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BERKELEYDB' ||
$tbl_type == 'INNODB') {
237 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'INNODB') {
240 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
241 <?php
echo $strCheckTable; ?
></a
> 
;
242 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?
>
247 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BERKELEYDB') {
250 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
251 <?php
echo $strAnalyzeTable; ?
></a
> 
;
252 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?
>
257 if ($tbl_type == 'MYISAM') {
260 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
261 <?php
echo $strRepairTable; ?
></a
> 
;
262 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?
>
267 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BERKELEYDB') {
270 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
271 <?php
echo $strOptimizeTable; ?
></a
> 
;
272 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?
>
279 } // end MYISAM or BERKELEYDB case
281 } // end MySQL >= 3.23.22
283 // loic1: "OPTIMIZE" statement is available for MyISAM and BERKELEYDB tables only and
284 // MyISAM/BERKELEYDB tables exists since MySQL 3.23.06/3.23.34
285 else if (PMA_MYSQL_INT_VERSION
>= 32306
286 && ($tbl_type == 'MYISAM' or $tbl_type == 'BERKELEYDB')) {
289 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
290 <?php
echo $strOptimizeTable; ?
></a
> 
;
291 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?
>
295 } // end 3.23.06 < MySQL < 3.23.22
298 <a href
="sql.php3?<?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'; ?>">
299 <?php
echo $strFlushTable; ?
></a
> 
;
300 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?
>
304 // Referential integrity check
305 // The Referential integrity check was intended for the non-InnoDB
306 // tables for which the relations are defined in pmadb
307 // so I assume that if the current table is InnoDB, I don't display
308 // this choice (InnoDB maintains integrity by itself)
310 if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
312 // we need this PMA_mysql_select_db if the user has access to more than one db
313 // and $db is not the last of the list, because PMA_availableDatabases()
314 // has made a PMA_mysql_select_db() on the last one
315 PMA_mysql_select_db($db);
316 $foreign = PMA_getForeigners($db, $table);
320 <!-- Referential integrity check
-->
322 <?php
echo $strReferentialIntegrity; ?
><br
/>
325 while (list($master, $arr) = each($foreign)){
326 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
327 . PMA_backquote($table) . ' LEFT JOIN '
328 . PMA_backquote($arr['foreign_table']);
329 if ($arr['foreign_table'] == $table) {
330 $foreign_table = $table . '1';
331 $join_query .= ' AS ' . PMA_backquote($foreign_table);
333 $foreign_table = $arr['foreign_table'];
335 $join_query .= ' ON '
336 . PMA_backquote($table) . '.' . PMA_backquote($master)
337 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
339 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
341 . PMA_backquote($table) . '.' . PMA_backquote($master)
344 . '<a href="sql.php3?' . $url_query
346 . urlencode($join_query)
347 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
348 . '</a><br />' . "\n";
349 unset($foreign_table);
355 } // end if ($result)
358 } // end if (!empty($cfg['Server']['relation']))
367 * Displays form controls
369 if (PMA_MYSQL_INT_VERSION
>= 32322) {
371 <!-- Table comments
-->
373 <form method
="post" action
="tbl_properties_operations.php3">
374 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
375 <?php
echo $strTableComments; ?
> 
;: 
;
376 <?php
$comment = ereg_replace('; InnoDB free:[^;]*$' , '', ereg_replace('^InnoDB free:[^;]*$', '', $show_comment)); ?
>
377 <input type
="hidden" name
="prev_comment" value
="<?php echo urlencode($comment); ?>" /> 
;
378 <input type
="text" name
="comment" maxlength
="60" size
="30" value
="<?php echo htmlspecialchars($comment); ?>" class="textfield" style
="vertical-align: middle" onfocus
="this.select()" /> 
;
379 <input type
="submit" name
="submitcomment" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
385 // modify robbat2 code - staybyte - 11. June 2001
386 $query = 'SHOW VARIABLES LIKE \'have_%\'';
387 $result = PMA_mysql_query($query);
388 if ($result != FALSE && mysql_num_rows($result) > 0) {
389 while ($tmp = PMA_mysql_fetch_array($result)) {
390 if (isset($tmp['Variable_name'])) {
391 switch ($tmp['Variable_name']) {
393 if ($tmp['Value'] == 'YES') {
398 if ($tmp['Value'] == 'YES') {
403 if ($tmp['Value'] == 'YES') {
408 if ($tmp['Value'] == 'YES') {
413 } // end if isset($tmp['Variable_name'])
417 mysql_free_result($result);
421 <form method
="post" action
="tbl_properties_operations.php3">
422 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
423 <?php
echo $strTableType; ?
> 
;: 
;
424 <select name
="tbl_type" style
="vertical-align: middle">
425 <option value
="MYISAM"<?php
if ($tbl_type == 'MYISAM') echo ' selected="selected"'; ?
>>MyISAM
</option
>
426 <option value
="HEAP"<?php
if ($tbl_type == 'HEAP') echo ' selected="selected"'; ?
>>Heap
</option
>
429 if (isset($tbl_bdb)) {
430 $tbl_types .= ' <option value="BERKELEYDB"'
431 . (($tbl_type == 'BERKELEYDB') ?
' selected="selected"' : '')
432 . '>Berkeley DB</option>' . "\n";
434 if (isset($tbl_gemini)) {
435 $tbl_types .= ' <option value="GEMINI"'
436 . (($tbl_type == 'GEMINI') ?
' selected="selected"' : '')
437 . '>Gemini</option>' . "\n";
439 if (isset($tbl_innodb)) {
440 $tbl_types .= ' <option value="INNODB"'
441 . (($tbl_type == 'INNODB') ?
' selected="selected"' : '')
442 . '>INNO DB</option>' . "\n";
444 if (isset($tbl_isam)) {
445 $tbl_types .= ' <option value="ISAM"'
446 . (($tbl_type == 'ISAM') ?
' selected="selected"' : '')
447 . '>ISAM</option>' . "\n";
452 <option value
="MERGE"<?php
if ($tbl_type == 'MRG_MYISAM') echo ' selected="selected"'; ?
>>Merge
</option
>
454 <input type
="submit" name
="submittype" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" /> 
;
455 <?php
echo PMA_showMySQLDocu('Table_types', 'Table_types') . "\n"; ?
>
460 if (PMA_MYSQL_INT_VERSION
>= 40100) {
462 . '<!-- Table character set -->' . "\n"
464 . ' <form method="post" action="tbl_properties_operations.php3">' . "\n"
465 . PMA_generate_common_hidden_inputs($db, $table, 3)
466 . ' ' . $strCharset . ' : ' . "\n"
467 . ' <select name="tbl_charset" style="vertical-align: middle">' . "\n";
468 $real_charset = strpos($tbl_charset, '_') ?
substr($tbl_charset, 0, strpos($tbl_charset, '_')) : $tbl_charset;
469 for ($i = 1; isset($mysql_charsets[$i]); $i++
) {
470 echo ' <option value="' . $mysql_charsets[$i] . '"' . ($mysql_charsets[$i] == $real_charset ?
' selected="selected"' : '') . '>' . $mysql_charsets[$i] . '</option>' . "\n";
473 unset($real_charset);
474 echo ' </select> ' . "\n"
475 . ' <input type="submit" name="submitcharset" value="' . $strGo . '" style="vertical-align: middle" /> ' . "\n"
482 <!-- Table options
-->
484 <?php
echo $strTableOptions; ?
>:<br
/>
485 <table border
="0" cellspacing
="0" cellpadding
="0">
488 <form method
="post" action
="tbl_properties_operations.php3">
489 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
491 <table border
="0" cellspacing
="1" cellpadding
="1">
493 <td align
="right"><input type
="checkbox" name
="pack_keys" id
="pack_keys_opt"
494 <?php
echo (isset($pack_keys) && $pack_keys == 1) ?
' checked="checked"' : ''; ?
> /></td
>
495 <td
><label
for="pack_keys_opt">pack_keys
</label
> 
; 
;</td
>
498 <td align
="right"><input type
="checkbox" name
="checksum" id
="checksum_opt"
499 <?php
echo (isset($checksum) && $checksum == 1) ?
' checked="checked"' : ''; ?
> /></td
>
500 <td
><label
for="checksum_opt">checksum
</label
> 
; 
;</td
>
503 <td align
="right"><input type
="checkbox" name
="delay_key_write" id
="delay_key_write_opt"
504 <?php
echo (isset($delay_key_write) && $delay_key_write == 1) ?
' checked="checked"' : ''; ?
> /></td
>
505 <td
><label
for="delay_key_write_opt">delay_key_write
</label
> 
; 
;</td
>
508 <td
><input type
="text" name
="auto_increment" id
="auto_increment_opt" class="textfield" style
="width: 30px"
509 <?php
echo (isset($auto_increment) && !empty($auto_increment) ?
' value="' . $auto_increment . '"' : ''); ?
> /></td
>
510 <td valign
="top"><label
for="auto_increment_opt">auto_increment
</label
> 
; 
;<input type
="submit" name
="submitoptions" value
="<?php echo $strGo; ?>" /></td
>
520 } // end if (PMA_MYSQL_INT_VERSION >= 32322)
523 * Displays the footer
526 require('./footer.inc.php3');