Remove single item clone
Load single row values in multi-edit git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@661 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
0abe5a5060
commit
0cd2afbb6b
20
edit.inc.php
20
edit.inc.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
$where = (isset($_GET["select"]) ? array() : where($_GET));
|
$where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : array()) : where($_GET));
|
||||||
$update = ($where && !$_GET["clone"]);
|
$update = ($where && !$_POST["clone"]);
|
||||||
$fields = fields($_GET["edit"]);
|
$fields = fields($_GET["edit"]);
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
if (isset($_GET["default"]) ? $field["auto_increment"] || preg_match('~text|blob~', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) {
|
if (isset($_GET["default"]) ? $field["auto_increment"] || preg_match('~text|blob~', $field["type"]) : !isset($field["privileges"][$update ? "update" : "insert"])) {
|
||||||
|
@ -39,15 +39,15 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || isset($_GET["select"]) ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]);
|
page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || (isset($_GET["select"]) && !$_POST["clone"]) ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]);
|
||||||
|
|
||||||
unset($row);
|
unset($row);
|
||||||
if ($_POST) {
|
if ($_POST["save"]) {
|
||||||
$row = (array) $_POST["fields"];
|
$row = (array) $_POST["fields"];
|
||||||
} elseif ($where) {
|
} elseif ($where) {
|
||||||
$select = array();
|
$select = array();
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
if (isset($field["privileges"]["select"]) && (!$_GET["clone"] || !$field["auto_increment"])) {
|
if (isset($field["privileges"]["select"]) && (!$_POST["clone"] || !$field["auto_increment"])) {
|
||||||
$select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
|
$select[] = ($field["type"] == "enum" || $field["type"] == "set" ? "1*" . idf_escape($name) . " AS " : "") . idf_escape($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,11 +67,9 @@ if ($fields) {
|
||||||
echo "<table cellspacing='0'>\n";
|
echo "<table cellspacing='0'>\n";
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
echo "<tr><th>" . htmlspecialchars($name) . "</th>";
|
echo "<tr><th>" . htmlspecialchars($name) . "</th>";
|
||||||
$value = (!isset($row) ? $field["default"] :
|
$value = (!isset($row) ? ($_POST["clone"] && $field["auto_increment"] ? "" : $field["default"])
|
||||||
(strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) :
|
: (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
|
||||||
($_POST["clone"] && $field["auto_increment"] ? "" :
|
);
|
||||||
$row[$name]
|
|
||||||
)));
|
|
||||||
input($name, $field, $value);
|
input($name, $field, $value);
|
||||||
if (isset($_GET["default"]) && $field["type"] == "timestamp") {
|
if (isset($_GET["default"]) && $field["type"] == "timestamp") {
|
||||||
if (!isset($create) && !$_POST) {
|
if (!isset($create) && !$_POST) {
|
||||||
|
@ -88,10 +86,10 @@ if ($fields) {
|
||||||
?>
|
?>
|
||||||
<p>
|
<p>
|
||||||
<input type="hidden" name="token" value="<?php echo $token; ?>" />
|
<input type="hidden" name="token" value="<?php echo $token; ?>" />
|
||||||
|
<input type="hidden" name="save" value="1" />
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET["select"])) {
|
if (isset($_GET["select"])) {
|
||||||
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
|
hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
|
||||||
echo "<input type='hidden' name='save' value='1' />\n";
|
|
||||||
}
|
}
|
||||||
if ($fields) {
|
if ($fields) {
|
||||||
echo '<input type="submit" value="' . lang('Save') . '" />';
|
echo '<input type="submit" value="' . lang('Save') . '" />';
|
||||||
|
|
|
@ -25,7 +25,7 @@ function input($name, $field, $value, $separator = "</td><td>") { //! pass empty
|
||||||
if (preg_match('~char|date|time~', $field["type"])) {
|
if (preg_match('~char|date|time~', $field["type"])) {
|
||||||
$options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now"));
|
$options = (preg_match('~char~', $field["type"]) ? array("", "md5", "sha1", "password", "uuid") : array("", "now"));
|
||||||
}
|
}
|
||||||
if (!isset($_GET["clone"]) && !isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
|
if (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET))) {
|
||||||
if (preg_match('~int|float|double|decimal~', $field["type"])) {
|
if (preg_match('~int|float|double|decimal~', $field["type"])) {
|
||||||
$options = array("", "+", "-");
|
$options = array("", "+", "-");
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,11 @@ function where($where) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function where_check($val) {
|
||||||
|
parse_str($val, $check);
|
||||||
|
return where($check);
|
||||||
|
}
|
||||||
|
|
||||||
function process_length($length) {
|
function process_length($length) {
|
||||||
global $enum_length;
|
global $enum_length;
|
||||||
return (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches) ? implode(",", $matches[0]) : preg_replace('~[^0-9,+-]~', '', $length));
|
return (preg_match("~^\\s*(?:$enum_length)(?:\\s*,\\s*(?:$enum_length))*\\s*\$~", $length) && preg_match_all("~$enum_length~", $length, $matches) ? implode(",", $matches[0]) : preg_replace('~[^0-9,+-]~', '', $length));
|
||||||
|
|
|
@ -98,9 +98,6 @@ if (isset($_GET["download"])) {
|
||||||
if (isset($_GET["function"])) {
|
if (isset($_GET["function"])) {
|
||||||
$_GET["procedure"] = $_GET["function"];
|
$_GET["procedure"] = $_GET["function"];
|
||||||
}
|
}
|
||||||
if (isset($_GET["clone"])) {
|
|
||||||
$_GET["edit"] = $_GET["clone"];
|
|
||||||
}
|
|
||||||
if (isset($_GET["sql"])) {
|
if (isset($_GET["sql"])) {
|
||||||
include "./sql.inc.php";
|
include "./sql.inc.php";
|
||||||
} elseif (isset($_GET["edit"])) {
|
} elseif (isset($_GET["edit"])) {
|
||||||
|
|
|
@ -74,8 +74,7 @@ if ($_POST && !$error) {
|
||||||
dump_table($_GET["select"], "");
|
dump_table($_GET["select"], "");
|
||||||
if (is_array($_POST["check"])) {
|
if (is_array($_POST["check"])) {
|
||||||
foreach ($_POST["check"] as $val) {
|
foreach ($_POST["check"] as $val) {
|
||||||
parse_str($val, $check);
|
dump_data($_GET["select"], "INSERT", "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where_check($val)) . " LIMIT 1");
|
||||||
dump_data($_GET["select"], "INSERT", "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", where($check)) . " LIMIT 1");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dump_data($_GET["select"], "INSERT", ($where ? "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", $where) : ""));
|
dump_data($_GET["select"], "INSERT", ($where ? "FROM " . idf_escape($_GET["select"]) . " WHERE " . implode(" AND ", $where) : ""));
|
||||||
|
@ -93,10 +92,10 @@ if ($_POST && !$error) {
|
||||||
if ($_POST["clone"]) {
|
if ($_POST["clone"]) {
|
||||||
$set[] = ($val !== false ? $val : idf_escape($name));
|
$set[] = ($val !== false ? $val : idf_escape($name));
|
||||||
} elseif ($val !== false) {
|
} elseif ($val !== false) {
|
||||||
$set[] = idf_escape($name) . " = $val";
|
$set[] = "\n" . idf_escape($name) . " = $val";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$command .= ($_POST["clone"] ? " SELECT " . implode(", ", $set) . " FROM " . idf_escape($_GET["select"]) : " SET " . implode(", ", $set));
|
$command .= ($_POST["clone"] ? "\nSELECT " . implode(", ", $set) . " FROM " . idf_escape($_GET["select"]) : " SET" . implode(",", $set));
|
||||||
}
|
}
|
||||||
if (!$_POST["delete"] && !$set) {
|
if (!$_POST["delete"] && !$set) {
|
||||||
// nothing
|
// nothing
|
||||||
|
@ -243,7 +242,7 @@ if (!$columns) {
|
||||||
echo "</tr></thead>\n";
|
echo "</tr></thead>\n";
|
||||||
}
|
}
|
||||||
$unique_idf = implode('&', unique_idf($row, $indexes));
|
$unique_idf = implode('&', unique_idf($row, $indexes));
|
||||||
echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');" />' . (count($select) == count($group) && $_GET["db"] != "information_schema" ? ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&' . $unique_idf . '">' . lang('edit') . '</a> <a href="' . htmlspecialchars($SELF) . 'clone=' . urlencode($_GET['select']) . '&' . $unique_idf . '">' . lang('clone') . '</a></td>' : '');
|
echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');" />' . (count($select) == count($group) && $_GET["db"] != "information_schema" ? ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
if (!isset($val)) {
|
if (!isset($val)) {
|
||||||
$val = "<i>NULL</i>";
|
$val = "<i>NULL</i>";
|
||||||
|
|
Loading…
Reference in a new issue