Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 61 lines (56 sloc) 2.579 kB
67096cd Prepare procedures
jakubvrana authored
1 <?php
79d1902 Substitute table name to $TABLE
jakubvrana authored
2 $PROCEDURE = $_GET["procedure"];
67096cd Prepare procedures
jakubvrana authored
3 $routine = (isset($_GET["function"]) ? "FUNCTION" : "PROCEDURE");
bf0c626 @vrana Hide routine language if not required
authored
4 $routine_languages = routine_languages();
67096cd Prepare procedures
jakubvrana authored
5
e2544b2 Remember drop result
jakubvrana authored
6 $dropped = false;
fd8948f Order of columns in table
jakubvrana authored
7 if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
8 $set = array();
9 $fields = (array) $_POST["fields"];
10 ksort($fields); // enforce fields order
11 foreach ($fields as $field) {
7352c28 Replace strlen() by != ""
jakubvrana authored
12 if ($field["field"] != "") {
55e2b75 @vrana Save bytes
authored
13 $set[] = (ereg("^($inout)\$", $field["inout"]) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
67096cd Prepare procedures
jakubvrana authored
14 }
15 }
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
16 $dropped = drop_create(
17 "DROP $routine " . idf_escape($PROCEDURE),
ef867e6 @vrana Trim identifiers (bug #3405309)
authored
18 "CREATE $routine " . idf_escape(trim($_POST["name"])) . " (" . implode(", ", $set) . ")" . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . (in_array($_POST["language"], $routine_languages) ? " LANGUAGE $_POST[language]" : "") . rtrim("\n$_POST[definition]", ";") . ";",
32d5b9c Inform about dropped routine, trigger and view
jakubvrana authored
19 substr(ME, 0, -1),
20 lang('Routine has been dropped.'),
21 lang('Routine has been altered.'),
22 lang('Routine has been created.'),
23 $PROCEDURE
24 );
67096cd Prepare procedures
jakubvrana authored
25 }
36d6864 Whitespace
jakubvrana authored
26
7352c28 Replace strlen() by != ""
jakubvrana authored
27 page_header(($PROCEDURE != "" ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . h($PROCEDURE) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure'))), $error);
8060c5b Routines
jakubvrana authored
28
29 $collations = get_vals("SHOW CHARACTER SET");
d2fa62d Order collations
jakubvrana authored
30 sort($collations);
d8df520 Initialize variables outside blocks
jakubvrana authored
31 $row = array("fields" => array());
8060c5b Routines
jakubvrana authored
32 if ($_POST) {
33 $row = $_POST;
34 $row["fields"] = (array) $row["fields"];
fd8948f Order of columns in table
jakubvrana authored
35 process_fields($row["fields"]);
7352c28 Replace strlen() by != ""
jakubvrana authored
36 } elseif ($PROCEDURE != "") {
79d1902 Substitute table name to $TABLE
jakubvrana authored
37 $row = routine($PROCEDURE, $routine);
38 $row["name"] = $PROCEDURE;
8060c5b Routines
jakubvrana authored
39 }
67096cd Prepare procedures
jakubvrana authored
40 ?>
8060c5b Routines
jakubvrana authored
41
42 <form action="" method="post" id="form">
faaa14e @vrana Print textarea as last field
authored
43 <p><?php echo lang('Name'); ?>: <input name="name" value="<?php echo h($row["name"]); ?>" maxlength="64">
bf0c626 @vrana Hide routine language if not required
authored
44 <?php echo ($routine_languages ? lang('Language') . ": " . html_select("language", $routine_languages, $row["language"]) : ""); ?>
dfe2540 Centralize nowrap
jakubvrana authored
45 <table cellspacing="0" class="nowrap">
46 <?php
47 edit_fields($row["fields"], $collations, $routine);
48 if (isset($_GET["function"])) {
49 echo "<tr><td>" . lang('Return type');
50 edit_type("returns", $row["returns"], $collations);
51 }
52 ?>
67096cd Prepare procedures
jakubvrana authored
53 </table>
6fffbbd Disable spell checking in SQL textareas
jakubvrana authored
54 <p><?php textarea("definition", $row["definition"]); ?>
8060c5b Routines
jakubvrana authored
55 <p>
ace55ed HTML instead of XHTML
jakubvrana authored
56 <input type="submit" value="<?php echo lang('Save'); ?>">
a93bc19 @vrana Create confirm function
authored
57 <?php if ($PROCEDURE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
740ae10 @vrana Don't send incomplete forms
authored
58 <?php if ($dropped) { ?><input type="hidden" name="dropped" value="1"><?php } ?>
59 <input type="hidden" name="token" value="<?php echo $token; ?>">
8060c5b Routines
jakubvrana authored
60 </form>
Something went wrong with that request. Please try again.