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();
22 * Reordering the table has been requested by the user
24 if (isset($submitorderby) && !empty($order_field)) {
25 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
26 . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
27 $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $err_url);
28 PMA_showMessage((get_magic_quotes_gpc()) ?
addslashes($strSuccess) : $strSuccess);
33 * Gets tables informations and displays top links
35 require('./tbl_properties_table_info.php3');
41 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
42 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url);
43 for ($i = 0; $row = PMA_mysql_fetch_array($result); $i++
) {
44 $columns[$i] = $row['Field'];
46 mysql_free_result($result);
56 if (PMA_MYSQL_INT_VERSION
>= 32334) {
58 <!-- Order the table
-->
60 <form method
="post" action
="tbl_properties_operations.php3">
61 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
62 <?php
echo $strAlterOrderBy; ?
> 
;:
63 <select name
="order_field" style
="vertical-align: middle">
67 while (list($junk, $fieldname) = each($columns)) {
68 echo ' <option value="' . urlencode($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
73 <input type
="submit" name
="submitorderby" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
74  
;<?php
echo $strSingly . "\n"; ?
>
82 <!-- Change table name
-->
84 <div style
="margin-bottom: 10px">
85 <form method
="post" action
="tbl_rename.php3"
86 onsubmit
="return emptyFormElements(this, 'new_name')">
87 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
88 <input type
="hidden" name
="reload" value
="1" />
89 <?php
echo $strRenameTable; ?
> 
;:
90 <input type
="text" size
="20" name
="new_name" value
="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus
="this.select()" /> 
;
91 <input type
="submit" value
="<?php echo $strGo; ?>" />
96 <!-- Move
and copy table
-->
97 <li style
="vertical-align: top">
98 <div style
="margin-bottom: 10px">
99 <table border
="0" cellspacing
="0" cellpadding
="0" style
="vertical-align: top">
102 <form method
="post" action
="tbl_move_copy.php3"
103 onsubmit
="return emptyFormElements(this, 'new_name')">
104 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
105 <input type
="hidden" name
="reload" value
="1" />
106 <input type
="hidden" name
="what" value
="data" />
107 <table border
="0" cellspacing
="0" cellpadding
="0">
110 <?php
echo $strMoveTable . "\n"; ?
>
115 <select name
="target_db">
116 <option value
=""></option
>
118 // The function used below is defined in "common.lib.php3"
119 PMA_availableDatabases('main.php3?' . PMA_generate_common_url());
120 for ($i = 0; $i < $num_dbs; $i++
) {
122 echo '<option value="' . str_replace('"', '"', $dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
128 <input type
="text" size
="20" name
="new_name" value
="<?php echo $table; ?>" class="textfield" onfocus
="this.select()" />
132 <td align
="<?php echo $cell_align_right; ?>" valign
="top">
133 <input type
="submit" name
="submit_move" value
="<?php echo $strGo; ?>" />
139 <td width
="25"> 
;</td
>
141 <form method
="post" action
="tbl_move_copy.php3"
142 onsubmit
="return emptyFormElements(this, 'new_name')">
143 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
144 <input type
="hidden" name
="reload" value
="1" />
145 <table border
="0" cellspacing
="0" cellpadding
="0">
147 <td colspan
="2" nowrap
="nowrap">
148 <?php
echo $strCopyTable . "\n"; ?
>
153 <select name
="target_db">
155 for ($i = 0; $i < $num_dbs; $i++
) {
157 echo '<option value="' . str_replace('"', '"', $dblist[$i]) . '"';
158 if ($dblist[$i] == $db) {
159 echo ' selected="selected"';
161 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
167 <input type
="text" size
="20" name
="new_name" class="textfield" onfocus
="this.select()" />
172 <input type
="radio" name
="what" value
="structure" id
="radio_copy_structure" checked
="checked" />
173 <label
for="radio_copy_structure"><?php
echo $strStrucOnly; ?
></label
> 
; 
;<br
/>
174 <input type
="radio" name
="what" value
="data" id
="radio_copy_data" />
175 <label
for="radio_copy_data"><?php
echo $strStrucData; ?
></label
> 
; 
;<br
/>
176 <input type
="radio" name
="what" value
="dataonly" id
="radio_copy_data" />
177 <label
for="radio_copy_data"><?php
echo $strDataOnly; ?
></label
> 
; 
;
179 <td align
="<?php echo $cell_align_right; ?>" valign
="top">
180 <input type
="submit" name
="submit_copy" value
="<?php echo $strGo; ?>" />
192 if (PMA_MYSQL_INT_VERSION
>= 32322) {
193 if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
195 <!-- Table maintenance
-->
196 <li style
="vertical-align: top">
197 <div style
="margin-bottom: 10px">
198 <table border
="0" cellspacing
="0" cellpadding
="0" style
="vertical-align: top">
200 <td
><?php
echo $strTableMaintenance; ?
> 
;: 
;</td
>
203 if ($tbl_type == 'MYISAM') {
206 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
207 <?php
echo $strCheckTable; ?
></a
> 
;
208 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?
>
210 <td
> 
;- 
;</td
>
214 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BDB') {
217 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
218 <?php
echo $strAnalyzeTable; ?
></a
> 
;
219 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?
>
230 if ($tbl_type == 'MYISAM') {
233 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
234 <?php
echo $strRepairTable; ?
></a
> 
;
235 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?
>
237 <td
> 
;- 
;</td
>
241 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BDB') {
244 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
245 <?php
echo $strOptimizeTable; ?
></a
> 
;
246 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?
>
257 } // end MYISAM or BDB case
259 } // end MySQL >= 3.23.22
261 // loic1: "OPTIMIZE" statement is available for MyISAM and BDB tables only and
262 // MyISAM/BDB tables exists since MySQL 3.23.06/3.23.34
263 else if (PMA_MYSQL_INT_VERSION
>= 32306
264 && ($tbl_type == 'MYISAM' or $tbl_type == 'BDB')) {
266 <!-- Table maintenance
-->
267 <li style
="vertical-align: top">
268 <div style
="margin-bottom: 10px">
269 <?php
echo $strTableMaintenance; ?
> 
;: 
;
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"; ?
>
277 } // end 3.23.06 < MySQL < 3.23.22
279 // Referential integrity check
280 if ($cfgRelation['relwork']) {
282 // we need this PMA_mysql_select_db if the user has access to more than one db
283 // and $db is not the last of the list, because PMA_availableDatabases()
284 // has made a PMA_mysql_select_db() on the last one
285 PMA_mysql_select_db($db);
286 $foreign = PMA_getForeigners($db, $table);
290 <!-- Referential integrity check
-->
291 <li style
="vertical-align: top">
292 <div style
="margin-bottom: 10px">
293 <?php
echo $strReferentialIntegrity; ?
><br
/>
296 while (list($master, $arr) = each($foreign)){
297 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
298 . PMA_backquote($table) . ' LEFT JOIN '
299 . PMA_backquote($arr['foreign_table']);
300 if ($arr['foreign_table'] == $table) {
301 $foreign_table = $table . '1';
302 $join_query .= ' AS ' . PMA_backquote($foreign_table);
304 $foreign_table = $arr['foreign_table'];
306 $join_query .= ' ON '
307 . PMA_backquote($table) . '.' . PMA_backquote($master)
308 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
310 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
312 . PMA_backquote($table) . '.' . PMA_backquote($master)
315 . '<a href="sql.php3?' . $url_query
317 . urlencode($join_query)
318 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
319 . '</a><br />' . "\n";
320 unset($foreign_table);
327 } // end if ($result)
330 } // end if (!empty($cfg['Server']['relation']))
333 <!-- Flushes the table
-->
335 <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'; ?>">
336 <?php
echo $strFlushTable; ?
></a
> 
;
337 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?
>
345 * Displays the footer
348 require('./footer.inc.php3');