foreach ($indexes as $name => $index) { ksort($index["columns"]); // enforce correct columns order $print = array(); foreach ($index["columns"] as $key => $val) { $print[] = "<i>" . h($val) . "</i>" . ($index["lengths"][$key] ? "(" . $index["lengths"][$key] . ")" : "") . ($index["descs"][$key] ? " DESC" : ""); } echo "<tr title='" . h($name) . "'><th>{$index['type']}<td>" . implode(", ", $print) . "\n"; } echo "</table>\n"; } echo '<p class="links"><a href="' . h(ME) . 'indexes=' . urlencode($TABLE) . '">' . lang('Alter indexes') . "</a>\n"; } if (fk_support($table_status)) { echo "<h3 id='foreign-keys'>" . lang('Foreign keys') . "</h3>\n"; $foreign_keys = foreign_keys($TABLE); if ($foreign_keys) { echo "<table cellspacing='0'>\n"; echo "<thead><tr><th>" . lang('Source') . "<td>" . lang('Target') . "<td>" . lang('ON DELETE') . "<td>" . lang('ON UPDATE') . "<td> </thead>\n"; foreach ($foreign_keys as $name => $foreign_key) { echo "<tr title='" . h($name) . "'>"; echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>"; echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ($foreign_key["ns"] != "" ? preg_replace('~ns=[^&]*~', "ns=" . urlencode($foreign_key["ns"]), ME) : ME)) . "table=" . urlencode($foreign_key["table"]) . "'>" . ($foreign_key["db"] != "" ? "<b>" . h($foreign_key["db"]) . "</b>." : "") . ($foreign_key["ns"] != "" ? "<b>" . h($foreign_key["ns"]) . "</b>." : "") . h($foreign_key["table"]) . "</a>"; echo "(<i>" . implode("</i>, <i>", array_map('h', $foreign_key["target"])) . "</i>)"; echo "<td>" . nbsp($foreign_key["on_delete"]) . "\n"; echo "<td>" . nbsp($foreign_key["on_update"]) . "\n"; echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>'; } echo "</table>\n"; } echo '<p class="links"><a href="' . h(ME) . 'foreign=' . urlencode($TABLE) . '">' . lang('Add foreign key') . "</a>\n";
/** Get foreign keys for table * @param string * @return array same format as foreign_keys() */ function foreignKeys($table) { return foreign_keys($table); }
echo '<div><input name="text_length" size="3" value="' . htmlspecialchars($text_length) . '" /></div>'; echo "</fieldset>\n"; } echo "<fieldset><legend>" . lang('Action') . "</legend><div><input type='submit' value='" . lang('Select') . "' /></div></fieldset>\n"; echo "</form>\n"; echo "<div style='clear: left;'> </div>\n"; $result = $mysql->query("SELECT SQL_CALC_FOUND_ROWS * {$from}"); if (!$result) { echo "<p class='error'>" . htmlspecialchars($mysql->error) . "</p>\n"; } else { if (!$result->num_rows) { echo "<p class='message'>" . lang('No rows.') . "</p>\n"; } else { $found_rows = $mysql->result($mysql->query(" SELECT FOUND_ROWS()")); $foreign_keys = array(); foreach (foreign_keys($_GET["select"]) as $foreign_key) { foreach ($foreign_key["source"] as $val) { $foreign_keys[$val][] = $foreign_key; } } echo "<form action='' method='post'>\n"; echo "<table border='1' cellspacing='0' cellpadding='2'>\n"; for ($j = 0; $row = $result->fetch_assoc(); $j++) { if (!$j) { echo '<thead><tr><td><label><input type="checkbox" name="delete_selected" value="1" onclick="var elems = this.form.elements; for (var i=0; i < elems.length; i++) if (elems[i].name == \'delete[]\') elems[i].checked = this.checked;" />' . lang('all') . '</label></td><th>' . implode("</th><th>", array_map('htmlspecialchars', array_keys($row))) . "</th></tr></thead>\n"; } $unique_idf = implode('&', unique_idf($row, $indexes)); echo '<tr><td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&' . $unique_idf . '">' . lang('edit') . "</a></td>"; foreach ($row as $key => $val) { if (!isset($val)) { $val = "<i>NULL</i>";