Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (78 sloc) 2.389 kb
bf12723f » jakubvrana
2007-07-09 Prepare for call
1 <?php
79d19028 » jakubvrana
2009-08-29 Substitute table name to $TABLE
2 $PROCEDURE = $_GET["call"];
3 page_header(lang('Call') . ": " . h($PROCEDURE), $error);
ae372aab » jakubvrana
2007-07-10 Database abstraction
4
79d19028 » jakubvrana
2009-08-29 Substitute table name to $TABLE
5 $routine = routine($PROCEDURE, (isset($_GET["callf"]) ? "FUNCTION" : "PROCEDURE"));
ec6185de » jakubvrana
2007-07-09 Calls
6 $in = array();
7 $out = array();
f442a52a » jakubvrana
2007-07-16 Separate routine()
8 foreach ($routine["fields"] as $i => $field) {
420ac01e » jakubvrana
2007-07-16 Separate $inout
9 if (substr($field["inout"], -3) == "OUT") {
ec6185de » jakubvrana
2007-07-09 Calls
10 $out[$i] = "@" . idf_escape($field["field"]) . " AS " . idf_escape($field["field"]);
11 }
420ac01e » jakubvrana
2007-07-16 Separate $inout
12 if (!$field["inout"] || substr($field["inout"], 0, 2) == "IN") {
ec6185de » jakubvrana
2007-07-09 Calls
13 $in[] = $i;
14 }
15 }
ae372aab » jakubvrana
2007-07-10 Database abstraction
16
eff527b3 » jakubvrana
2008-04-10 Move error output to page_header()
17 if (!$error && $_POST) {
ec6185de » jakubvrana
2007-07-09 Calls
18 $call = array();
f442a52a » jakubvrana
2007-07-16 Separate routine()
19 foreach ($routine["fields"] as $key => $field) {
ec6185de » jakubvrana
2007-07-09 Calls
20 if (in_array($key, $in)) {
a0def479 » jakubvrana
2009-07-27 Date localization
21 $val = process_input($field);
2d8002b7 » jakubvrana
2007-07-11 File upload error
22 if ($val === false) {
23 $val = "''";
24 }
ec6185de » jakubvrana
2007-07-09 Calls
25 if (isset($out[$key])) {
64d616c0 » jakubvrana
2009-09-22 Rename get_dbh to connection
26 $connection->query("SET @" . idf_escape($field["field"]) . " = $val");
ec6185de » jakubvrana
2007-07-09 Calls
27 }
28 }
29 $call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val);
bf12723f » jakubvrana
2007-07-09 Prepare for call
30 }
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
31 $query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")";
e6726941 »
2010-05-07 Rename $driver to $jush
32 echo "<p><code class='jush-$jush'>" . h($query) . "</code> <a href='" . h(ME) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a>\n";
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
33 if (!$connection->multi_query($query)) {
c1130ed5 » jakubvrana
2009-12-17 Simplify SQL syntax errors everywhere
34 echo "<p class='error'>" . error() . "\n";
bf12723f » jakubvrana
2007-07-09 Prepare for call
35 } else {
417b29fe »
2011-04-17 Fix 'Commands out of sync' (thanks to Vlasta Neubauer)
36 $connection2 = connect();
37 if (is_object($connection2)) {
38 $connection2->select_db(DB);
39 }
ae372aab » jakubvrana
2007-07-10 Database abstraction
40 do {
64d616c0 » jakubvrana
2009-09-22 Rename get_dbh to connection
41 $result = $connection->store_result();
ae372aab » jakubvrana
2007-07-10 Database abstraction
42 if (is_object($result)) {
417b29fe »
2011-04-17 Fix 'Commands out of sync' (thanks to Vlasta Neubauer)
43 select($result, $connection2);
ae372aab » jakubvrana
2007-07-10 Database abstraction
44 } else {
64d616c0 » jakubvrana
2009-09-22 Rename get_dbh to connection
45 echo "<p class='message'>" . lang('Routine has been called, %d row(s) affected.', $connection->affected_rows) . "\n";
ae372aab » jakubvrana
2007-07-10 Database abstraction
46 }
64d616c0 » jakubvrana
2009-09-22 Rename get_dbh to connection
47 } while ($connection->next_result());
ec6185de » jakubvrana
2007-07-09 Calls
48 if ($out) {
64d616c0 » jakubvrana
2009-09-22 Rename get_dbh to connection
49 select($connection->query("SELECT " . implode(", ", $out)));
ec6185de » jakubvrana
2007-07-09 Calls
50 }
bf12723f » jakubvrana
2007-07-09 Prepare for call
51 }
52 }
53 ?>
ec6185de » jakubvrana
2007-07-09 Calls
54
bf12723f » jakubvrana
2007-07-09 Prepare for call
55 <form action="" method="post">
56 <?php
ec6185de » jakubvrana
2007-07-09 Calls
57 if ($in) {
d30facef » jakubvrana
2009-05-01 Remove useless table attributes (thanks to Juraj Krivda)
58 echo "<table cellspacing='0'>\n";
ec6185de » jakubvrana
2007-07-09 Calls
59 foreach ($in as $key) {
f442a52a » jakubvrana
2007-07-16 Separate routine()
60 $field = $routine["fields"][$key];
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
61 $name = $field["field"];
5edca067 » jakubvrana
2010-04-28 Display routine parameter type in title (thanks to paranoiq)
62 echo "<tr><th>" . $adminer->fieldName($field);
3f5b6834 » jakubvrana
2010-04-21 Reintegrate sqlite branch
63 $value = $_POST["fields"][$name];
e9ae7435 »
2010-10-22 Fix set prefill
64 if ($value != "") {
65 if ($field["type"] == "enum") {
66 $value = +$value;
67 }
68 if ($field["type"] == "set") {
69 $value = array_sum($value);
70 }
ec6185de » jakubvrana
2007-07-09 Calls
71 }
1e4d11e9 » jakubvrana
2009-07-23 Select from foreign keys in Editor
72 input($field, $value, (string) $_POST["function"][$name]); // param name can be empty
ace55ed1 » jakubvrana
2009-07-11 HTML instead of XHTML
73 echo "\n";
bf12723f » jakubvrana
2007-07-09 Prepare for call
74 }
75 echo "</table>\n";
76 }
77 ?>
b295a841 » jakubvrana
2007-07-11 Whitespace
78 <p>
ace55ed1 » jakubvrana
2009-07-11 HTML instead of XHTML
79 <input type="submit" value="<?php echo lang('Call'); ?>">
740ae10a »
2011-03-08 Don't send incomplete forms
80 <input type="hidden" name="token" value="<?php echo $token; ?>">
bf12723f » jakubvrana
2007-07-09 Prepare for call
81 </form>
Something went wrong with that request. Please try again.