2007-07-16 23:08:24 +00:00
|
|
|
<?php
|
2009-08-29 13:57:50 +00:00
|
|
|
$PROCEDURE = $_GET["procedure"];
|
2007-07-16 23:08:24 +00:00
|
|
|
$routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
|
|
|
|
|
2007-08-04 19:39:18 +00:00
|
|
|
$dropped = false;
|
2008-05-07 11:22:08 +00:00
|
|
|
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
2009-10-13 19:33:50 +00:00
|
|
|
$set = array();
|
|
|
|
$fields = (array) $_POST["fields"];
|
|
|
|
ksort($fields); // enforce fields order
|
|
|
|
foreach ($fields as $field) {
|
2010-01-09 23:33:41 +00:00
|
|
|
if ($field["field"] != "") {
|
2009-10-13 19:33:50 +00:00
|
|
|
$set[] = (in_array($field["inout"], $inout) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
|
2007-07-16 23:08:24 +00:00
|
|
|
}
|
|
|
|
}
|
2009-10-13 19:33:50 +00:00
|
|
|
$dropped = drop_create(
|
|
|
|
"DROP $routine " . idf_escape($PROCEDURE),
|
|
|
|
"CREATE $routine " . idf_escape($_POST["name"]) . " (" . implode(", ", $set) . ")" . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . "\n$_POST[definition]",
|
|
|
|
substr(ME, 0, -1),
|
|
|
|
lang('Routine has been dropped.'),
|
|
|
|
lang('Routine has been altered.'),
|
|
|
|
lang('Routine has been created.'),
|
|
|
|
$PROCEDURE
|
|
|
|
);
|
2007-07-16 23:08:24 +00:00
|
|
|
}
|
2009-07-20 12:12:55 +00:00
|
|
|
|
2010-01-09 23:33:41 +00:00
|
|
|
page_header(($PROCEDURE != "" ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
|
2007-07-17 09:12:15 +00:00
|
|
|
|
|
|
|
$collations = get_vals("SHOW CHARACTER SET");
|
2009-06-29 10:10:59 +00:00
|
|
|
sort($collations);
|
2008-07-10 15:39:24 +00:00
|
|
|
$row = array("fields" => array());
|
2007-07-17 09:12:15 +00:00
|
|
|
if ($_POST) {
|
|
|
|
$row = $_POST;
|
|
|
|
$row["fields"] = (array) $row["fields"];
|
2008-05-07 11:22:08 +00:00
|
|
|
process_fields($row["fields"]);
|
2010-01-09 23:33:41 +00:00
|
|
|
} elseif ($PROCEDURE != "") {
|
2009-08-29 13:57:50 +00:00
|
|
|
$row = routine($PROCEDURE, $routine);
|
|
|
|
$row["name"] = $PROCEDURE;
|
2007-07-17 09:12:15 +00:00
|
|
|
}
|
2007-07-16 23:08:24 +00:00
|
|
|
?>
|
2007-07-17 09:12:15 +00:00
|
|
|
|
|
|
|
<form action="" method="post" id="form">
|
2010-10-11 19:10:58 +00:00
|
|
|
<p><?php echo lang('Name'); ?>: <input name="name" value="<?php echo h($row["name"]); ?>" maxlength="64">
|
2010-01-28 15:17:20 +00:00
|
|
|
<table cellspacing="0" class="nowrap">
|
|
|
|
<?php
|
|
|
|
edit_fields($row["fields"], $collations, $routine);
|
|
|
|
if (isset($_GET["function"])) {
|
|
|
|
echo "<tr><td>" . lang('Return type');
|
|
|
|
edit_type("returns", $row["returns"], $collations);
|
|
|
|
}
|
|
|
|
?>
|
2007-07-16 23:08:24 +00:00
|
|
|
</table>
|
2010-04-26 16:22:24 +00:00
|
|
|
<p><?php textarea("definition", $row["definition"]); ?>
|
2007-07-17 09:12:15 +00:00
|
|
|
<p>
|
2009-07-11 20:30:40 +00:00
|
|
|
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
|
|
|
<?php if ($dropped) { ?><input type="hidden" name="dropped" value="1"><?php } ?>
|
|
|
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
2010-01-09 23:33:41 +00:00
|
|
|
<?php if ($PROCEDURE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
2007-07-17 09:12:15 +00:00
|
|
|
</form>
|