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 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
62 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
63 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
64 <input type
="hidden" name
="db" value
="<?php echo htmlspecialchars($db); ?>" />
65 <input type
="hidden" name
="table" value
="<?php echo htmlspecialchars($table); ?>" />
66 <?php
echo $strAlterOrderBy; ?
> 
;:
67 <select name
="order_field" style
="vertical-align: middle">
71 while (list($junk, $fieldname) = each($columns)) {
72 echo ' <option value="' . urlencode($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
77 <input type
="submit" name
="submitorderby" value
="<?php echo $strGo; ?>" style
="vertical-align: middle" />
78  
;<?php
echo $strSingly . "\n"; ?
>
86 <!-- Change table name
-->
88 <div style
="margin-bottom: 10px">
89 <form method
="post" action
="tbl_rename.php3"
90 onsubmit
="return emptyFormElements(this, 'new_name')">
91 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
92 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
93 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
94 <input type
="hidden" name
="db" value
="<?php echo htmlspecialchars($db); ?>" />
95 <input type
="hidden" name
="table" value
="<?php echo htmlspecialchars($table); ?>" />
96 <input type
="hidden" name
="reload" value
="1" />
97 <?php
echo $strRenameTable; ?
> 
;:
98 <input type
="text" size
="20" name
="new_name" value
="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus
="this.select()" /> 
;
99 <input type
="submit" value
="<?php echo $strGo; ?>" />
104 <!-- Move
and copy table
-->
105 <li style
="vertical-align: top">
106 <div style
="margin-bottom: 10px">
107 <table border
="0" cellspacing
="0" cellpadding
="0" style
="vertical-align: top">
110 <form method
="post" action
="tbl_move_copy.php3"
111 onsubmit
="return emptyFormElements(this, 'new_name')">
112 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
113 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
114 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
115 <input type
="hidden" name
="db" value
="<?php echo htmlspecialchars($db); ?>" />
116 <input type
="hidden" name
="table" value
="<?php echo htmlspecialchars($table); ?>" />
117 <input type
="hidden" name
="reload" value
="1" />
118 <input type
="hidden" name
="what" value
="data" />
119 <table border
="0" cellspacing
="0" cellpadding
="0">
122 <?php
echo $strMoveTable . "\n"; ?
>
127 <select name
="target_db">
128 <option value
=""></option
>
130 // The function used below is defined in "common.lib.php3"
131 PMA_availableDatabases('main.php3?lang=' . $lang . '&server=' . $server);
132 for ($i = 0; $i < $num_dbs; $i++
) {
134 echo '<option value="' . str_replace('"', '"', $dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
140 <input type
="text" size
="20" name
="new_name" value
="<?php echo $table; ?>" class="textfield" onfocus
="this.select()" />
144 <td align
="<?php echo $cell_align_right; ?>" valign
="top">
145 <input type
="submit" name
="submit_move" value
="<?php echo $strGo; ?>" />
151 <td width
="25"> 
;</td
>
153 <form method
="post" action
="tbl_move_copy.php3"
154 onsubmit
="return emptyFormElements(this, 'new_name')">
155 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
156 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
157 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
158 <input type
="hidden" name
="db" value
="<?php echo htmlspecialchars($db); ?>" />
159 <input type
="hidden" name
="table" value
="<?php echo htmlspecialchars($table); ?>" />
160 <input type
="hidden" name
="reload" value
="1" />
161 <table border
="0" cellspacing
="0" cellpadding
="0">
163 <td colspan
="2" nowrap
="nowrap">
164 <?php
echo $strCopyTable . "\n"; ?
>
169 <select name
="target_db">
171 for ($i = 0; $i < $num_dbs; $i++
) {
173 echo '<option value="' . str_replace('"', '"', $dblist[$i]) . '"';
174 if ($dblist[$i] == $db) {
175 echo ' selected="selected"';
177 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
183 <input type
="text" size
="20" name
="new_name" class="textfield" onfocus
="this.select()" />
188 <input type
="radio" name
="what" value
="structure" id
="radio_copy_structure" checked
="checked" />
189 <label
for="radio_copy_structure"><?php
echo $strStrucOnly; ?
></label
> 
; 
;<br
/>
190 <input type
="radio" name
="what" value
="data" id
="radio_copy_data" />
191 <label
for="radio_copy_data"><?php
echo $strStrucData; ?
></label
> 
; 
;<br
/>
192 <input type
="radio" name
="what" value
="dataonly" id
="radio_copy_data" />
193 <label
for="radio_copy_data"><?php
echo $strDataOnly; ?
></label
> 
; 
;
195 <td align
="<?php echo $cell_align_right; ?>" valign
="top">
196 <input type
="submit" name
="submit_copy" value
="<?php echo $strGo; ?>" />
208 if (PMA_MYSQL_INT_VERSION
>= 32322) {
209 if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
211 <!-- Table maintenance
-->
212 <li style
="vertical-align: top">
213 <div style
="margin-bottom: 10px">
214 <table border
="0" cellspacing
="0" cellpadding
="0" style
="vertical-align: top">
216 <td
><?php
echo $strTableMaintenance; ?
> 
;: 
;</td
>
219 if ($tbl_type == 'MYISAM') {
222 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
223 <?php
echo $strCheckTable; ?
></a
> 
;
224 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?
>
226 <td
> 
;- 
;</td
>
230 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BDB') {
233 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
234 <?php
echo $strAnalyzeTable; ?
></a
> 
;
235 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?
>
246 if ($tbl_type == 'MYISAM') {
249 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
250 <?php
echo $strRepairTable; ?
></a
> 
;
251 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?
>
253 <td
> 
;- 
;</td
>
257 if ($tbl_type == 'MYISAM' ||
$tbl_type == 'BDB') {
260 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
261 <?php
echo $strOptimizeTable; ?
></a
> 
;
262 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?
>
273 } // end MYISAM or BDB case
275 } // end MySQL >= 3.23.22
277 // loic1: "OPTIMIZE" statement is available for MyISAM and BDB tables only and
278 // MyISAM/BDB tables exists since MySQL 3.23.06/3.23.34
279 else if (PMA_MYSQL_INT_VERSION
>= 32306
280 && ($tbl_type == 'MYISAM' or $tbl_type == 'BDB')) {
282 <!-- Table maintenance
-->
283 <li style
="vertical-align: top">
284 <div style
="margin-bottom: 10px">
285 <?php
echo $strTableMaintenance; ?
> 
;: 
;
286 <a href
="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
287 <?php
echo $strOptimizeTable; ?
></a
> 
;
288 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?
>
293 } // end 3.23.06 < MySQL < 3.23.22
295 // Referential integrity check
296 if ($cfgRelation['relwork']) {
298 // we need this PMA_mysql_select_db if the user has access to more than one db
299 // and $db is not the last of the list, because PMA_availableDatabases()
300 // has made a PMA_mysql_select_db() on the last one
301 PMA_mysql_select_db($db);
302 $foreign = PMA_getForeigners($db, $table);
306 <!-- Referential integrity check
-->
307 <li style
="vertical-align: top">
308 <div style
="margin-bottom: 10px">
309 <?php
echo $strReferentialIntegrity; ?
><br
/>
312 while (list($master, $arr) = each($foreign)){
313 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
314 . PMA_backquote($table) . ' LEFT JOIN '
315 . PMA_backquote($arr['foreign_table']);
316 if ($arr['foreign_table'] == $table) {
317 $foreign_table = $table . '1';
318 $join_query .= ' AS ' . PMA_backquote($foreign_table);
320 $foreign_table = $arr['foreign_table'];
322 $join_query .= ' ON '
323 . PMA_backquote($table) . '.' . PMA_backquote($master)
324 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
326 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
328 . PMA_backquote($table) . '.' . PMA_backquote($master)
331 . '<a href="sql.php3?' . $url_query
333 . urlencode($join_query)
334 . '">' . $master . ' -> ' . $arr['foreign_table'] . '.' . $arr['foreign_field']
335 . '</a><br />' . "\n";
336 unset($foreign_table);
343 } // end if ($result)
346 } // end if (!empty($cfg['Server']['relation']))
349 <!-- Flushes the table
-->
351 <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'; ?>">
352 <?php
echo $strFlushTable; ?
></a
> 
;
353 <?php
echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?
>
361 * Displays the footer
364 require('./footer.inc.php3');