sorry, wrong version checked in
[phpmyadmin/arisferyanto.git] / tbl_properties_operations.php
blob6b3fc9ba1c38ae1d7d1682c90557a9eafd889b9b
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once('./libraries/common.lib.php');
7 /**
8 * Runs common work
9 */
10 require('./tbl_properties_common.php');
11 //$err_url = 'tbl_properties_operations.php' . $err_url;
12 $url_query .= '&amp;goto=tbl_properties_operations.php&amp;back=tbl_properties_operations.php';
15 /**
16 * Gets relation settings
18 require_once('./libraries/relation.lib.php');
19 $cfgRelation = PMA_getRelationsParam();
21 /**
22 * Gets available MySQL charsets and storage engines
24 require_once('./libraries/mysql_charsets.lib.php');
25 require_once('./libraries/storage_engines.lib.php');
27 // reselect current db (needed in some cases probably due to
28 // the calling of relation.lib.php)
29 PMA_DBI_select_db($db);
31 $reread_info = FALSE;
33 /**
34 * Updates table comment, type and options if required
36 if (isset($submitcomment)) {
37 if (empty($prev_comment) || urldecode($prev_comment) != $comment) {
38 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
39 $result = PMA_DBI_query($sql_query);
40 $message = $strSuccess;
41 $reread_info = TRUE;
44 if (isset($submittype)) {
45 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $new_tbl_type;
46 $result = PMA_DBI_query($sql_query);
47 $message = $strSuccess;
48 $reread_info = TRUE;
50 if (isset($submitcollation)) {
51 // since something modifies $tbl_collation between the moment it is
52 // set from $_POST and this point, need to restore it
53 // (bug seen in MySQL 5.0.4)
54 $tbl_collation = $_POST['tbl_collation'];
55 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT' . PMA_generateCharsetQueryPart($tbl_collation);
56 $result = PMA_DBI_query($sql_query);
57 $message = $strSuccess;
58 unset($tbl_collation);
59 $reread_info = TRUE;
61 if (isset($submitoptions)) {
62 $sql_query = 'ALTER TABLE ' . PMA_backquote($table);
63 if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM') {
64 $sql_query .= isset($new_pack_keys) ? ' pack_keys=1': ' pack_keys=0';
66 if ($tbl_type == 'MYISAM') {
67 $sql_query .= (isset($new_checksum) ? ' checksum=1': ' checksum=0')
68 . (isset($new_delay_key_write) ? ' delay_key_write=1': ' delay_key_write=0');
70 // nijel: Here should be version check for InnoDB, however it is supported
71 // in 5.0.x x>4, 4.1.y y>12 and also works in 4.0.11, so I decided not to
72 // check for version
73 if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') {
74 $sql_query .= !empty($new_auto_increment) ? ' auto_increment=' . PMA_sqlAddslashes($new_auto_increment) : '';
76 $result = PMA_DBI_query($sql_query);
77 $message = $strSuccess;
78 $reread_info = TRUE;
81 if ($reread_info) {
82 require('./tbl_properties_table_info.php');
84 unset($reread_info);
86 /**
87 * Reordering the table has been requested by the user
89 if (isset($submitorderby) && !empty($order_field)) {
90 $sql_query = 'ALTER TABLE ' . PMA_backquote($table)
91 . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
92 if (isset($order_order) && $order_order == 'desc') {
93 $sql_query .= ' DESC';
95 $result = PMA_DBI_query($sql_query);
96 $message = $result ? $strSuccess : $strError;
97 } // end if
99 /**
100 * Gets tables informations
102 require_once('./tbl_properties_table_info.php');
105 * Displays top menu links
107 require_once('./tbl_properties_links.php');
110 * Get columns names
112 $local_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
113 $result = PMA_DBI_query($local_query);
114 for ($i = 0; $row = PMA_DBI_fetch_assoc($result); $i++) {
115 $columns[$i] = $row['Field'];
117 PMA_DBI_free_result($result);
118 unset($result);
121 <table border="0" align="left" cellpadding="3" cellspacing="0">
122 <?php
125 * Displays the page
128 if (PMA_MYSQL_INT_VERSION >= 32334) {
130 <!-- Order the table -->
132 <form method="post" action="tbl_properties_operations.php">
133 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
134 <tr>
135 <th class="tblHeaders" colspan="2" align="left"><?php echo $strAlterOrderBy; ?>:&nbsp;</th></tr>
136 <tr>
137 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
138 <select name="order_field" style="vertical-align: middle">
139 <?php
140 echo "\n";
141 foreach ($columns AS $junk => $fieldname) {
142 echo ' <option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
144 unset($columns);
146 </select>&nbsp;<?php echo $strSingly . "\n"; ?>
147 <select name="order_order" style="vertical-align: middle">
148 <option value="asc"><?php echo $strAscending; ?></option>
149 <option value="desc"><?php echo $strDescending; ?></option>
150 </select>
151 </td>
152 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">
153 <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
154 </td>
155 </tr>
156 </form>
157 <tr><td colspan="2" height="5"></td></tr>
158 <?php
160 echo "\n";
162 <!-- Change table name -->
163 <form method="post" action="tbl_rename.php" onsubmit="return emptyFormElements(this, 'new_name')">
164 <tr>
165 <th class="tblHeaders" colspan="2" align="left">
166 <?php echo $strRenameTable; ?>:&nbsp;
167 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
168 <input type="hidden" name="reload" value="1" />
169 </th>
170 </tr>
171 <tr>
172 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
173 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" />&nbsp;
174 </td>
175 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">
176 <input type="submit" value="<?php echo $strGo; ?>" />
177 </td>
178 </tr>
179 </form>
180 <tr><td colspan="2" height="5"></td></tr>
181 <!-- Move table -->
182 <form method="post" action="tbl_move_copy.php" onsubmit="return emptyFormElements(this, 'new_name')">
183 <tr>
184 <th class="tblHeaders" colspan="2" align="left">
185 <?php echo $strMoveTable . "\n"; ?>
186 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
187 <input type="hidden" name="reload" value="1" />
188 <input type="hidden" name="what" value="data" />
189 </th>
190 </tr>
191 <tr>
192 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" nowrap="nowrap">
193 <select name="target_db">
194 <?php
195 // The function used below is defined in "common.lib.php"
196 PMA_availableDatabases('main.php?' . PMA_generate_common_url());
197 for ($i = 0; $i < $num_dbs; $i++) {
198 echo ' ';
199 echo '<option value="' . htmlspecialchars($dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
200 echo "\n";
201 } // end for
203 </select>
204 &nbsp;<b>.</b>&nbsp;
205 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" class="textfield" onfocus="this.select()" />
206 </td>
207 <td align="<?php echo $cell_align_right; ?>" bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
208 <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
209 </td>
210 </tr>
211 </form>
212 <tr><td colspan="2" height="5"></td></tr>
213 <!-- Copy table -->
214 <form method="post" action="tbl_move_copy.php" onsubmit="return emptyFormElements(this, 'new_name')">
215 <tr>
216 <th class="tblHeaders" colspan="2" align="left">
217 <?php echo $strCopyTable . "\n"; ?>
218 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
219 <input type="hidden" name="reload" value="1" />
220 </th>
221 </tr>
222 <tr>
223 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" colspan="2" nowrap="nowrap">
224 <select name="target_db">
225 <?php
226 for ($i = 0; $i < $num_dbs; $i++) {
227 echo ' ';
228 echo '<option value="' . htmlspecialchars($dblist[$i]) . '"';
229 if ($dblist[$i] == $db) {
230 echo ' selected="selected"';
232 echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
233 echo "\n";
234 } // end for
236 </select>
237 &nbsp;<b>.</b>&nbsp;
238 <input type="text" size="20" name="new_name" class="textfield" onfocus="this.select()" />
239 </td>
240 </tr>
241 <tr>
242 <td nowrap="nowrap" bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
243 <input type="radio" name="what" value="structure" id="radio_copy_structure" style="vertical-align: middle" /><label for="radio_copy_structure"><?php echo $strStrucOnly; ?></label>&nbsp;&nbsp;<br />
244 <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>&nbsp;&nbsp;<br />
245 <input type="radio" name="what" value="dataonly" id="radio_copy_dataonly" style="vertical-align: middle" /><label for="radio_copy_dataonly"><?php echo $strDataOnly; ?></label>&nbsp;&nbsp;<br />
247 <input type="checkbox" name="drop_if_exists" value="true" id="checkbox_drop" style="vertical-align: middle" /><label for="checkbox_drop"><?php echo $strStrucDrop; ?></label>&nbsp;&nbsp;<br />
248 <input type="checkbox" name="sql_auto_increment" value="1" id="checkbox_auto_increment" style="vertical-align: middle" /><label for="checkbox_auto_increment"><?php echo $strAddAutoIncrement; ?></label><br />
249 <?php
250 // display "Add constraints" choice only if there are
251 // foreign keys
252 if (PMA_getForeigners($db, $table, '', 'innodb')) {
254 <input type="checkbox" name="constraints" value="1" id="checkbox_constraints" style="vertical-align: middle" /><label for="checkbox_constraints"><?php echo $strAddConstraints; ?></label><br />
255 <?php
256 } // endif
257 if (isset($_COOKIE) && isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') {
258 $pma_switch_to_new = 'true';
261 <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>&nbsp;&nbsp;
262 </td>
263 <td align="<?php echo $cell_align_right; ?>" valign="bottom" bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
264 <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
265 </td>
266 </tr>
267 </form>
268 <tr><td colspan="2" height="5"></td></tr>
269 <?php
272 * Displays form controls
275 <!-- Table comments -->
276 <form method="post" action="tbl_properties_operations.php">
277 <tr>
278 <th colspan="2" class="tblHeaders" align="left">
279 <?php
280 echo PMA_generate_common_hidden_inputs($db, $table);
281 echo $strTableComments . '&nbsp;';
282 if (strstr($show_comment, '; InnoDB free') === FALSE) {
283 if (strstr($show_comment, 'InnoDB free') === FALSE) {
284 // only user entered comment
285 $comment = $show_comment;
286 } else {
287 // here we have just InnoDB generated part
288 $comment = '';
290 } else {
291 // remove InnoDB comment from end, just the minimal part (*? is non greedy)
292 $comment = preg_replace('@; InnoDB free:.*?$@' , '', $show_comment);
295 <input type="hidden" name="prev_comment" value="<?php echo urlencode($comment); ?>" />&nbsp;
296 </th>
297 <tr>
298 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
299 <input type="text" name="comment" maxlength="60" size="30" value="<?php echo htmlspecialchars($comment); ?>" class="textfield" style="vertical-align: middle" onfocus="this.select()" />&nbsp;
300 </td>
301 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">
302 <input type="submit" name="submitcomment" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
303 </td>
304 </tr>
305 </form>
306 <tr><td colspan="2" height="5"></td></tr>
307 <!-- Table type -->
308 <?php
309 // modify robbat2 code - staybyte - 11. June 2001
310 $result = PMA_DBI_query('SHOW VARIABLES LIKE \'have_%\';');
311 if ($result) {
312 while ($tmp = PMA_DBI_fetch_assoc($result)) {
313 if (isset($tmp['Variable_name'])) {
314 switch ($tmp['Variable_name']) {
315 case 'have_bdb':
316 if ($tmp['Value'] == 'YES') {
317 $tbl_bdb = TRUE;
319 break;
320 case 'have_gemini':
321 if ($tmp['Value'] == 'YES') {
322 $tbl_gemini = TRUE;
324 break;
325 case 'have_innodb':
326 if ($tmp['Value'] == 'YES') {
327 $tbl_innodb = TRUE;
329 break;
330 case 'have_isam':
331 if ($tmp['Value'] == 'YES') {
332 $tbl_isam = TRUE;
334 break;
335 } // end switch
336 } // end if isset($tmp['Variable_name'])
337 } // end while
338 } // end if $result
340 PMA_DBI_free_result($result);
341 echo "\n";
343 <form method="post" action="tbl_properties_operations.php">
344 <tr>
345 <th colspan="2" class="tblHeaders" align="left">
346 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
347 <?php echo $strTableType; ?>:&nbsp;
348 <?php echo PMA_showMySQLDocu('Table_types', 'Table_types') . "\n"; ?>
349 </th>
350 </tr>
351 <tr>
352 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
353 <?php echo PMA_generateEnginesDropdown('new_tbl_type', NULL, FALSE, $tbl_type, 4); ?>
354 </td>
355 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right">
356 <input type="submit" name="submittype" value="<?php echo $strGo; ?>" />
357 </td>
358 </tr>
359 </form>
360 <tr><td colspan="2" height="5"></td></tr>
361 <?php
363 if (PMA_MYSQL_INT_VERSION >= 40100) {
364 echo "\n"
365 . '<!-- Table character set -->' . "\n"
366 . ' <form method="post" action="tbl_properties_operations.php">' . "\n"
367 . ' <tr>' . "\n"
368 . ' <th colspan="2" class="tblHeaders" align="left">' . "\n"
369 . PMA_generate_common_hidden_inputs($db, $table, 3)
370 . ' ' . $strCollation . ':&nbsp;' . "\n"
371 . ' </th>' . "\n"
372 . ' </tr>' . "\n"
373 . ' <tr>' . "\n"
374 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n"
375 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', NULL, $tbl_collation, FALSE, 3)
376 . ' </td>' . "\n"
377 . ' <td bgcolor="' . $cfg['BgcolorOne'] . '" align="right">' . "\n"
378 . ' <input type="submit" name="submitcollation" value="' . $strGo . '" style="vertical-align: middle" />' . "\n"
379 . ' </td>' . "\n"
380 . ' </tr>' . "\n"
381 . ' </form>' . "\n"
382 . ' <tr><td colspan="2" height="5"></td></tr>' . "\n";
384 // PACK_KEYS: MyISAM or ISAM
385 // DELAY_KEY_WRITE, CHECKSUM, : MyISAM only
386 // AUTO_INCREMENT: MyISAM and InnoDB since 5.0.3
388 // nijel: Here should be version check for InnoDB, however it is supported
389 // in 5.0.x x>4, 4.1.y y>12 and also works in 4.0.11, so I decided not to
390 // check for version
391 if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM' || $tbl_type == 'INNODB') {
393 <!-- Table options -->
394 <form method="post" action="tbl_properties_operations.php">
395 <tr>
396 <th colspan="2" class="tblHeaders" align="left">
397 <?php echo $strTableOptions; ?>:&nbsp;
398 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
399 </th>
400 </tr>
401 <tr>
402 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
403 <?php
404 if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM') {
406 <input type="checkbox" name="new_pack_keys" id="pack_keys_opt"
407 <?php echo (isset($pack_keys) && $pack_keys == 1) ? ' checked="checked"' : ''; ?> style="vertical-align: middle" /><label for="pack_keys_opt">pack_keys</label><br />
408 <?php
409 } // end if (MYISAM|ISAM)
410 if ($tbl_type == 'MYISAM') {
412 <input type="checkbox" name="new_checksum" id="checksum_opt"
413 <?php echo (isset($checksum) && $checksum == 1) ? ' checked="checked"' : ''; ?> style="vertical-align: middle" /><label for="checksum_opt">checksum</label><br />
415 <input type="checkbox" name="new_delay_key_write" id="delay_key_write_opt"
416 <?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 />
418 <?php
419 } // end if (MYISAM)
420 if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') {
422 <input type="text" name="new_auto_increment" id="auto_increment_opt" class="textfield"
423 <?php echo (isset($auto_increment) && !empty($auto_increment) ? ' value="' . $auto_increment . '"' : ''); ?> style="width: 30px; vertical-align: middle" />&nbsp;<label for="auto_increment_opt">auto_increment</label>
424 </td>
425 <?php
426 } // end if (MYISAM|INNODB)
428 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right" valign="bottom">
429 <input type="submit" name="submitoptions" value="<?php echo $strGo; ?>" />
430 </td>
431 </tr>
432 </form>
433 <?php
434 } // end if (MYISAM or ISAM)
436 </table>
437 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="25" height="1" border="0" align="left" />
438 <!----->
439 <table border="0" cellpadding="3" cellspacing="0">
440 <tr>
441 <th class="tblHeaders" colspan="2" align="left">
442 <?php echo $strTableMaintenance; ?>
443 </th>
444 </tr>
445 <?php
446 if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB' || $tbl_type == 'INNODB') {
447 echo "\n";
448 if ($tbl_type == 'MYISAM' || $tbl_type == 'INNODB') {
450 <tr>
451 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
452 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
453 <?php echo $strCheckTable; ?></a>&nbsp;
454 </td>
455 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
456 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE') . "\n"; ?>
457 </td>
458 </tr>
459 <?php
461 echo "\n";
462 if ($tbl_type == 'INNODB') {
464 <tr>
465 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
466 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' TYPE=InnoDB'); ?>">
467 <?php echo $strDefragment; ?></a>&nbsp;
468 </td>
469 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
470 <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting') . "\n"; ?>
471 </td>
472 </tr>
473 <?php
475 echo "\n";
476 if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') {
478 <tr>
479 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
480 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
481 <?php echo $strAnalyzeTable; ?></a>&nbsp;
482 </td>
483 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
484 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE') . "\n";?>
485 </td>
486 </tr>
487 <?php
489 echo "\n";
490 if ($tbl_type == 'MYISAM') {
492 <tr>
493 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
494 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
495 <?php echo $strRepairTable; ?></a>&nbsp;
496 </td>
497 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
498 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE') . "\n"; ?>
499 </td>
500 </tr>
501 <?php
503 echo "\n";
504 if ($tbl_type == 'MYISAM' || $tbl_type == 'BERKELEYDB') {
506 <tr>
507 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
508 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
509 <?php echo $strOptimizeTable; ?></a>&nbsp;
510 </td>
511 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
512 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE') . "\n"; ?>
513 </td>
514 </tr>
515 <?php
517 echo "\n";
519 <?php
520 } // end MYISAM or BERKELEYDB case
521 echo "\n";
523 <tr>
524 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
525 <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('FLUSH TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenFlushed, htmlspecialchars($table))); if ($cfg['ShowTooltip']) echo '&amp;reload=1'; ?>">
526 <?php echo $strFlushTable; ?></a>&nbsp;
527 </td>
528 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
529 <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH') . "\n"; ?>
530 </td>
531 </tr>
533 <?php
534 // Referential integrity check
535 // The Referential integrity check was intended for the non-InnoDB
536 // tables for which the relations are defined in pmadb
537 // so I assume that if the current table is InnoDB, I don't display
538 // this choice (InnoDB maintains integrity by itself)
540 if ($cfgRelation['relwork'] && $tbl_type != "INNODB") {
542 // we need this PMA_DBI_select_db if the user has access to more than one db
543 // and $db is not the last of the list, because PMA_availableDatabases()
544 // has made a PMA_DBI_select_db() on the last one
545 PMA_DBI_select_db($db);
546 $foreign = PMA_getForeigners($db, $table);
548 if ($foreign) {
550 <!-- Referential integrity check -->
551 <tr>
552 <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" colspan="2">
553 <?php echo $strReferentialIntegrity; ?><br />
554 <?php
555 echo "\n";
556 foreach ($foreign AS $master => $arr) {
557 $join_query = 'SELECT ' . PMA_backquote($table) . '.* FROM '
558 . PMA_backquote($table) . ' LEFT JOIN '
559 . PMA_backquote($arr['foreign_table']);
560 if ($arr['foreign_table'] == $table) {
561 $foreign_table = $table . '1';
562 $join_query .= ' AS ' . PMA_backquote($foreign_table);
563 } else {
564 $foreign_table = $arr['foreign_table'];
566 $join_query .= ' ON '
567 . PMA_backquote($table) . '.' . PMA_backquote($master)
568 . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
569 . ' WHERE '
570 . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field'])
571 . ' IS NULL AND '
572 . PMA_backquote($table) . '.' . PMA_backquote($master)
573 . ' IS NOT NULL';
574 echo ' '
575 . '<a href="sql.php?' . $url_query
576 . '&amp;sql_query='
577 . urlencode($join_query)
578 . '">' . $master . '&nbsp;->&nbsp;' . $arr['foreign_table'] . '.' . $arr['foreign_field']
579 . '</a><br />' . "\n";
580 unset($foreign_table);
581 unset($join_query);
582 } // end while
584 </td>
585 </tr>
586 <?php
587 } // end if ($result)
588 echo "\n";
590 } // end if (!empty($cfg['Server']['relation']))
592 </table>
593 <?php
596 * Displays the footer
598 echo "\n";
599 require_once('./footer.inc.php');