Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: tbl_properties_operations.php,v 2.6 2004/01/05 13:29:09 rabus Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00005 00009 require('./tbl_properties_common.php'); 00010 //$err_url = 'tbl_properties_operations.php' . $err_url; 00011 $url_query .= '&goto=tbl_properties_operations.php&back=tbl_properties_operations.php'; 00012 00013 00017 require_once('./libraries/relation.lib.php'); 00018 $cfgRelation = PMA_getRelationsParam(); 00019 00023 require_once('./libraries/mysql_charsets.lib.php'); 00024 00028 if (isset($submitcomment)) { 00029 if (empty($prev_comment) || urldecode($prev_comment) != $comment) { 00030 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\''; 00031 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); 00032 $message = $strSuccess; 00033 } 00034 } 00035 if (isset($submittype)) { 00036 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $tbl_type; 00037 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); 00038 $message = $strSuccess; 00039 } 00040 if (isset($submitcharset)) { 00041 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT CHARACTER SET = ' . $tbl_charset; 00042 $result = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query, '', $err_url); 00043 $message = $strSuccess; 00044 } 00045 if (isset($submitoptions)) { 00046 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) 00047 . (isset($pack_keys) ? ' pack_keys=1': ' pack_keys=0') 00048 . (isset($checksum) ? ' checksum=1': ' checksum=0') 00049 . (isset($delay_key_write) ? ' delay_key_write=1': ' delay_key_write=0') 00050 . (isset($auto_increment) ? ' auto_increment=' . PMA_sqlAddslashes($auto_increment) : ''); 00051 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); 00052 $message = $strSuccess; 00053 } 00054 00055 // Displays a message if a query had been submitted 00056 if (isset($message)) { 00057 PMA_showMessage($message); 00058 } 00059 00060 00061 00065 if (isset($submitorderby) && !empty($order_field)) { 00066 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) 00067 . ' ORDER BY ' . PMA_backquote(urldecode($order_field)); 00068 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url); 00069 PMA_showMessage($strSuccess); 00070 } // end if 00071 00072 00076 require('./tbl_properties_table_info.php'); 00077 00078 00082 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db); 00083 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url); 00084 for ($i = 0; $row = PMA_mysql_fetch_array($result); $i++) { 00085 $columns[$i] = $row['Field']; 00086 } 00087 mysql_free_result($result); 00088 00089 00093 ?> 00094 <ul> 00095 00096 <?php 00097 if (PMA_MYSQL_INT_VERSION >= 32334) { 00098 ?> 00099 <!-- Order the table --> 00100 <li> 00101 <form method="post" action="tbl_properties_operations.php"> 00102 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00103 <?php echo $strAlterOrderBy; ?> : 00104 <select name="order_field" style="vertical-align: middle"> 00105 <?php 00106 echo "\n"; 00107 foreach($columns AS $junk => $fieldname) { 00108 echo ' <option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n"; 00109 } 00110 unset($columns); 00111 ?> 00112 </select> 00113 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" style="vertical-align: middle" /> 00114 <?php echo $strSingly . "\n"; ?> 00115 </form> 00116 </li> 00117 <?php 00118 } 00119 echo "\n"; 00120 ?> 00121 00122 <!-- Change table name --> 00123 <li> 00124 <form method="post" action="tbl_rename.php" 00125 onsubmit="return emptyFormElements(this, 'new_name')"> 00126 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00127 <input type="hidden" name="reload" value="1" /> 00128 <?php echo $strRenameTable; ?> : 00129 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" /> 00130 <input type="submit" value="<?php echo $strGo; ?>" /> 00131 </form> 00132 </li> 00133 00134 <!-- Move table --> 00135 <li> 00136 <?php echo $strMoveTable . "\n"; ?> 00137 <form method="post" action="tbl_move_copy.php" 00138 onsubmit="return emptyFormElements(this, 'new_name')"> 00139 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00140 <input type="hidden" name="reload" value="1" /> 00141 <input type="hidden" name="what" value="data" /> 00142 <table border="0" cellspacing="0" cellpadding="0"> 00143 <tr> 00144 <td> 00145 <select name="target_db"> 00146 <?php 00147 // The function used below is defined in "common.lib.php" 00148 PMA_availableDatabases('main.php?' . PMA_generate_common_url()); 00149 for ($i = 0; $i < $num_dbs; $i++) { 00150 echo ' '; 00151 echo '<option value="' . htmlspecialchars($dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>'; 00152 echo "\n"; 00153 } // end for 00154 ?> 00155 </select> 00156 <b>.</b> 00157 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" /> 00158 </td> 00159 </tr> 00160 <tr> 00161 <td align="<?php echo $cell_align_right; ?>" valign="top"> 00162 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" /> 00163 </td> 00164 </tr> 00165 </table> 00166 </form> 00167 </li> 00168 00169 <!-- Copy table --> 00170 <li> 00171 <?php echo $strCopyTable . "\n"; ?> 00172 <form method="post" action="tbl_move_copy.php" 00173 onsubmit="return emptyFormElements(this, 'new_name')"> 00174 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00175 <input type="hidden" name="reload" value="1" /> 00176 <table border="0" cellspacing="0" cellpadding="0"> 00177 <tr> 00178 <td colspan="2"> 00179 <select name="target_db"> 00180 <?php 00181 for ($i = 0; $i < $num_dbs; $i++) { 00182 echo ' '; 00183 echo '<option value="' . htmlspecialchars($dblist[$i]) . '"'; 00184 if ($dblist[$i] == $db) { 00185 echo ' selected="selected"'; 00186 } 00187 echo '>' . htmlspecialchars($dblist[$i]) . '</option>'; 00188 echo "\n"; 00189 } // end for 00190 ?> 00191 </select> 00192 <b>.</b> 00193 <input type="text" size="20" name="new_name" class="textfield" onfocus="this.select()" /> 00194 </td> 00195 </tr> 00196 <tr> 00197 <td nowrap="nowrap"> 00198 <input type="radio" name="what" value="structure" id="radio_copy_structure" checked="checked" /> 00199 <label for="radio_copy_structure"><?php echo $strStrucOnly; ?></label> <br /> 00200 <input type="radio" name="what" value="data" id="radio_copy_data" /> 00201 <label for="radio_copy_data"><?php echo $strStrucData; ?></label> <br /> 00202 <input type="radio" name="what" value="dataonly" id="radio_copy_dataonly" /> 00203 <label for="radio_copy_dataonly"><?php echo $strDataOnly; ?></label> <br /> 00204 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" /> 00205 <label for="checkbox_drop"><?php echo $strStrucDrop; ?></label> <br /> 00206 <input type="checkbox" name="auto_increment" value="1" id="checkbox_auto_increment" /> 00207 <label for="checkbox_auto_increment"><?php echo $strAddAutoIncrement; ?></label><br /> 00208 <?php 00209 // display "Add constraints" choice only if there are 00210 // foreign keys 00211 if (PMA_getForeigners($db, $table, '', 'innodb')) { 00212 ?> 00213 <input type="checkbox" name="constraints" value="1" id="checkbox_constraints" /> 00214 <label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br /> 00215 <?php 00216 } // endif 00217 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') { 00218 $pma_switch_to_new = 'true'; 00219 } 00220 ?> 00221 <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"' : ''); ?>/> 00222 <label for="checkbox_switch"><?php echo $strSwitchToTable; ?></label> 00223 </td> 00224 <td align="<?php echo $cell_align_right; ?>" valign="top"> 00225 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" /> 00226 </td> 00227 </tr> 00228 </table> 00229 </form> 00230 </li> 00231 00232 <!-- Table maintenance --> 00233 <li> 00234 <?php echo $strTableMaintenance; ?> 00235 <ul> 00236 <?php 00237 if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB' || $tbl_type == 'INNODB') { 00238 echo "\n"; 00239 if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') { 00240 ?> 00241 <li> 00242 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>"> 00243 <?php echo $strCheckTable; ?></a> 00244 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?> 00245 </li> 00246 <?php 00247 } 00248 echo "\n"; 00249 if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') { 00250 ?> 00251 <li> 00252 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>"> 00253 <?php echo $strAnalyzeTable; ?></a> 00254 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?> 00255 </li> 00256 <?php 00257 } 00258 echo "\n"; 00259 if ($tbl_type == 'MYISAM') { 00260 ?> 00261 <li> 00262 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>"> 00263 <?php echo $strRepairTable; ?></a> 00264 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?> 00265 </li> 00266 <?php 00267 } 00268 echo "\n"; 00269 if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') { 00270 ?> 00271 <li> 00272 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"> 00273 <?php echo $strOptimizeTable; ?></a> 00274 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?> 00275 </li> 00276 <?php 00277 } 00278 echo "\n"; 00279 ?> 00280 <?php 00281 } // end MYISAM or BERKELEYDB case 00282 echo "\n"; 00283 ?> 00284 <li> 00285 <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'; ?>"> 00286 <?php echo $strFlushTable; ?></a> 00287 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?> 00288 </li> 00289 00290 <?php 00291 // Referential integrity check 00292 // The Referential integrity check was intended for the non-InnoDB 00293 // tables for which the relations are defined in pmadb 00294 // so I assume that if the current table is InnoDB, I don't display 00295 // this choice (InnoDB maintains integrity by itself) 00296 00297 if ($cfgRelation['relwork'] && $tbl_type != "INNODB") { 00298 00299 // we need this PMA_mysql_select_db if the user has access to more than one db 00300 // and $db is not the last of the list, because PMA_availableDatabases() 00301 // has made a PMA_mysql_select_db() on the last one 00302 PMA_mysql_select_db($db); 00303 $foreign = PMA_getForeigners($db, $table); 00304 00305 if ($foreign) { 00306 ?> 00307 <!-- Referential integrity check --> 00308 <li> 00309 <?php echo $strReferentialIntegrity; ?><br /> 00310 <?php 00311 echo "\n"; 00312 foreach($foreign AS $master => $arr) { 00313 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM ' 00314 . PMA_backquote($table) . ' LEFT JOIN ' 00315 . PMA_backquote($arr['foreign_table']); 00316 if ($arr['foreign_table'] == $table) { 00317 $foreign_table = $table . '1'; 00318 $join_query .= ' AS ' . PMA_backquote($foreign_table); 00319 } else { 00320 $foreign_table = $arr['foreign_table']; 00321 } 00322 $join_query .= ' ON ' 00323 . PMA_backquote($table) . '.' . PMA_backquote($master) 00324 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field']) 00325 . ' WHERE ' 00326 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field']) 00327 . ' IS NULL AND ' 00328 . PMA_backquote($table) . '.' . PMA_backquote($master) 00329 . ' IS NOT NULL'; 00330 echo ' ' 00331 . '<a href="sql.php?' . $url_query 00332 . '&sql_query=' 00333 . urlencode($join_query) 00334 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field'] 00335 . '</a><br />' . "\n"; 00336 unset($foreign_table); 00337 unset($join_query); 00338 } // end while 00339 ?> 00340 </li> 00341 <?php 00342 } // end if ($result) 00343 echo "\n"; 00344 00345 } // end if (!empty($cfg['Server']['relation'])) 00346 ?> 00347 <br /> 00348 </ul> 00349 </li> 00350 00351 <?php 00352 00356 ?> 00357 <!-- Table comments --> 00358 <li> 00359 <form method="post" action="tbl_properties_operations.php"> 00360 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00361 <?php echo $strTableComments; ?> : 00362 <?php $comment = ereg_replace('; InnoDB free:.*$' , '', ereg_replace('^InnoDB free:.*$', '', $show_comment)); ?> 00363 <input type="hidden" name="prev_comment" value="<?php echo urlencode($comment); ?>" /> 00364 <input type="text" name="comment" maxlength="60" size="30" value="<?php echo htmlspecialchars($comment); ?>" class="textfield" style="vertical-align: middle" onfocus="this.select()" /> 00365 <input type="submit" name="submitcomment" value="<?php echo $strGo; ?>" style="vertical-align: middle" /> 00366 </form> 00367 </li> 00368 00369 <!-- Table type --> 00370 <?php 00371 // modify robbat2 code - staybyte - 11. June 2001 00372 $query = 'SHOW VARIABLES LIKE \'have_%\''; 00373 $result = PMA_mysql_query($query); 00374 if ($result != FALSE && mysql_num_rows($result) > 0) { 00375 while ($tmp = PMA_mysql_fetch_array($result)) { 00376 if (isset($tmp['Variable_name'])) { 00377 switch ($tmp['Variable_name']) { 00378 case 'have_bdb': 00379 if ($tmp['Value'] == 'YES') { 00380 $tbl_bdb = TRUE; 00381 } 00382 break; 00383 case 'have_gemini': 00384 if ($tmp['Value'] == 'YES') { 00385 $tbl_gemini = TRUE; 00386 } 00387 break; 00388 case 'have_innodb': 00389 if ($tmp['Value'] == 'YES') { 00390 $tbl_innodb = TRUE; 00391 } 00392 break; 00393 case 'have_isam': 00394 if ($tmp['Value'] == 'YES') { 00395 $tbl_isam = TRUE; 00396 } 00397 break; 00398 } // end switch 00399 } // end if isset($tmp['Variable_name']) 00400 } // end while 00401 } // end if $result 00402 00403 mysql_free_result($result); 00404 echo "\n"; 00405 ?> 00406 <li> 00407 <form method="post" action="tbl_properties_operations.php"> 00408 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00409 <?php echo $strTableType; ?> : 00410 <select name="tbl_type" style="vertical-align: middle"> 00411 <option value="MYISAM"<?php if ($tbl_type == 'MYISAM') echo ' selected="selected"'; ?>>MyISAM</option> 00412 <option value="HEAP"<?php if ($tbl_type == 'HEAP') echo ' selected="selected"'; ?>>Heap</option> 00413 <?php 00414 $tbl_types = "\n"; 00415 if (isset($tbl_bdb)) { 00416 $tbl_types .= ' <option value="BERKELEYDB"' 00417 . (($tbl_type == 'BERKELEYDB') ? ' selected="selected"' : '') 00418 . '>Berkeley DB</option>' . "\n"; 00419 } 00420 if (isset($tbl_gemini)) { 00421 $tbl_types .= ' <option value="GEMINI"' 00422 . (($tbl_type == 'GEMINI') ? ' selected="selected"' : '') 00423 . '>Gemini</option>' . "\n"; 00424 } 00425 if (isset($tbl_innodb)) { 00426 $tbl_types .= ' <option value="INNODB"' 00427 . (($tbl_type == 'INNODB') ? ' selected="selected"' : '') 00428 . '>INNO DB</option>' . "\n"; 00429 } 00430 if (isset($tbl_isam)) { 00431 $tbl_types .= ' <option value="ISAM"' 00432 . (($tbl_type == 'ISAM') ? ' selected="selected"' : '') 00433 . '>ISAM</option>' . "\n"; 00434 } 00435 00436 echo $tbl_types; 00437 ?> 00438 <option value="MERGE"<?php if ($tbl_type == 'MRG_MYISAM') echo ' selected="selected"'; ?>>Merge</option> 00439 </select> 00440 <input type="submit" name="submittype" value="<?php echo $strGo; ?>" style="vertical-align: middle" /> 00441 <?php echo PMA_showMySQLDocu('Table_types', 'Table_types') . "\n"; ?> 00442 </form> 00443 </li> 00444 <?php 00445 00446 if (PMA_MYSQL_INT_VERSION >= 40100) { 00447 echo "\n" 00448 . '<!-- Table character set -->' . "\n" 00449 . ' <li>' . "\n" 00450 . ' <form method="post" action="tbl_properties_operations.php">' . "\n" 00451 . PMA_generate_common_hidden_inputs($db, $table, 3) 00452 . ' ' . $strCharset . ' : ' . "\n" 00453 . ' <select name="tbl_charset" style="vertical-align: middle">' . "\n"; 00454 $real_charset = strpos($tbl_charset, '_') ? substr($tbl_charset, 0, strpos($tbl_charset, '_')) : $tbl_charset; 00455 for ($i = 1; isset($mysql_charsets[$i]); $i++) { 00456 echo ' <option value="' . $mysql_charsets[$i] . '"' . ($mysql_charsets[$i] == $real_charset ? ' selected="selected"' : '') . '>' . $mysql_charsets[$i] . '</option>' . "\n"; 00457 } 00458 unset($i); 00459 unset($real_charset); 00460 echo ' </select> ' . "\n" 00461 . ' <input type="submit" name="submitcharset" value="' . $strGo . '" style="vertical-align: middle" /> ' . "\n" 00462 . ' </form>' . "\n" 00463 . ' </li>' . "\n"; 00464 } 00465 00466 ?> 00467 00468 <!-- Table options --> 00469 <li> 00470 <?php echo $strTableOptions; ?>:<br /> 00471 <table border="0" cellspacing="0" cellpadding="0"> 00472 <tr> 00473 <td valign="top"> 00474 <form method="post" action="tbl_properties_operations.php"> 00475 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?> 00476 00477 <table border="0" cellspacing="1" cellpadding="1"> 00478 <tr> 00479 <td align="right"><input type="checkbox" name="pack_keys" id="pack_keys_opt" 00480 <?php echo (isset($pack_keys) && $pack_keys == 1) ? ' checked="checked"' : ''; ?> /></td> 00481 <td><label for="pack_keys_opt">pack_keys</label> </td> 00482 </tr> 00483 <tr> 00484 <td align="right"><input type="checkbox" name="checksum" id="checksum_opt" 00485 <?php echo (isset($checksum) && $checksum == 1) ? ' checked="checked"' : ''; ?> /></td> 00486 <td><label for="checksum_opt">checksum</label> </td> 00487 </tr> 00488 <tr> 00489 <td align="right"><input type="checkbox" name="delay_key_write" id="delay_key_write_opt" 00490 <?php echo (isset($delay_key_write) && $delay_key_write == 1) ? ' checked="checked"' : ''; ?> /></td> 00491 <td><label for="delay_key_write_opt">delay_key_write</label> </td> 00492 </tr> 00493 <tr> 00494 <td><input type="text" name="auto_increment" id="auto_increment_opt" class="textfield" style="width: 30px" 00495 <?php echo (isset($auto_increment) && !empty($auto_increment) ? ' value="' . $auto_increment . '"' : ''); ?> /></td> 00496 <td valign="top"><label for="auto_increment_opt">auto_increment</label> <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" /></td> 00497 </tr> 00498 </table> 00499 </form> 00500 </td> 00501 </tr> 00502 </table> 00503 </li> 00504 </ul> 00505 <?php 00506 00510 echo "\n"; 00511 require_once('./footer.inc.php'); 00512 ?>