Prepare for routines edit

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@196 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-07-16 14:28:32 +00:00
parent e4d5bbd1fb
commit 1e750c4813
2 changed files with 16 additions and 7 deletions

View file

@ -135,6 +135,7 @@ function routine($name, $type) {
"unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$match[7] $match[6]"))),
"null" => true,
"inout" => strtoupper($match[1]),
//! detect character set
);
$params[$i] = $field;
}
@ -360,16 +361,17 @@ function process_input($name, $field) {
}
}
function edit_fields($fields, $collations, $type = "table") {
global $types, $unsigned;
function edit_fields($fields, $collations, $type = "TABLE") {
global $types, $unsigned, $inout;
?>
<table border="0" cellspacing="0" cellpadding="2">
<thead><tr>
<?php if ($type == "PROCEDURE") { ?><td><?php echo lang('In-Out'); ?></td><?php } ?>
<th><?php echo lang('Column name'); ?></th>
<td><?php echo lang('Type'); ?></td>
<td><?php echo lang('Length'); ?></td>
<td><?php echo lang('Options'); ?></td>
<?php if ($type == "table") { ?>
<?php if ($type == "TABLE") { ?>
<td><?php echo lang('NULL'); ?></td>
<td><input type="radio" name="auto_increment" value="" /><?php echo lang('Auto Increment'); ?></td>
<td id="comment-0"><?php echo lang('Comment'); ?></td>
@ -382,11 +384,12 @@ foreach ($fields as $i => $field) {
$i++;
?>
<tr>
<?php if ($type == "PROCEDURE") { ?><td><select name="inout"><?php echo optionlist($inout, $field["inout"]); ?></select></td><?php } ?>
<th><input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo htmlspecialchars($field[($_POST ? "orig" : "field")]); ?>" /><input name="fields[<?php echo $i; ?>][field]" value="<?php echo htmlspecialchars($field["field"]); ?>" maxlength="64" /></th>
<td><select name="fields[<?php echo $i; ?>][type]" onchange="type_change(this);"><?php echo optionlist(array_keys($types), $field["type"]); ?></select></td>
<td><input name="fields[<?php echo $i; ?>][length]" value="<?php echo htmlspecialchars($field["length"]); ?>" size="3" /></td>
<td><select name="fields[<?php echo $i; ?>][collation]"><option value="">(<?php echo lang('collation'); ?>)</option><?php echo optionlist($collations, $field["collation"]); ?></select> <select name="fields[<?php echo $i; ?>][unsigned]"><?php echo optionlist($unsigned, $field["unsigned"]); ?></select></td>
<?php if ($type == "table") { ?>
<?php if ($type == "TABLE") { ?>
<td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?> /></td>
<td><input type="radio" name="auto_increment" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
<td id="comment-<?php echo $i; ?>"><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>

View file

@ -49,6 +49,9 @@ if (isset($_GET["dump"])) {
if (isset($_GET["callf"])) {
$_GET["call"] = $_GET["callf"];
}
if (isset($_GET["createf"])) {
$_GET["createp"] = $_GET["createf"];
}
if (isset($_GET["sql"])) {
include "./sql.inc.php";
} elseif (isset($_GET["edit"])) {
@ -65,6 +68,8 @@ if (isset($_GET["dump"])) {
include "./foreign.inc.php";
} elseif (isset($_GET["createv"])) {
include "./createv.inc.php";
} elseif (isset($_GET["createp"])) {
include "./createp.inc.php";
} elseif (isset($_GET["processlist"])) {
include "./processlist.inc.php";
} else {
@ -72,20 +77,21 @@ if (isset($_GET["dump"])) {
page_header(htmlspecialchars(lang('Database') . ": " . $_GET["db"]));
echo '<p><a href="' . htmlspecialchars($SELF) . 'database=">' . lang('Alter database') . "</a></p>\n";
if ($mysql->server_info >= 5) {
echo "<h2>" . lang('Routines') . "</h2>\n";
$result = $mysql->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = '" . $mysql->escape_string($_GET["db"]) . "'");
if ($result->num_rows) {
echo "<h2>" . lang('Routines') . "</h2>\n";
echo "<table border='0' cellspacing='0' cellpadding='2'>\n";
while ($row = $result->fetch_assoc()) {
echo "<tr valign='top'>";
echo "<tr>";
echo "<th>" . htmlspecialchars($row["ROUTINE_TYPE"]) . "</th>";
echo '<td><a href="' . htmlspecialchars($SELF) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'callf' : 'call') . '=' . urlencode($row["ROUTINE_NAME"]) . '">' . htmlspecialchars($row["ROUTINE_NAME"]) . '</a></td>';
echo "<td><pre class='jush-sql'>" . htmlspecialchars($row["ROUTINE_DEFINITION"]) . "</pre></td>";
echo '<td><a href="' . htmlspecialchars($SELF) . ($row["ROUTINE_TYPE"] == "FUNCTION" ? 'createf' : 'createp') . '=' . urlencode($row["ROUTINE_NAME"]) . '">' . lang('Alter') . "</a></td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
$result->free();
echo '<p><a href="' . htmlspecialchars($SELF) . 'createp=">' . lang('Create procedure') . '</a> <a href="' . htmlspecialchars($SELF) . 'createf=">' . lang('Create function') . "</a></p>\n";
echo '<p><a href="' . htmlspecialchars($SELF) . 'createv=">' . lang('Create view') . "</a></p>\n";
}
}