Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Timestamps

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@248 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
commit 27067912d10ebd91837816deb52bdafab01bf46c 1 parent f099d94
jakubvrana authored
Showing with 13 additions and 7 deletions.
  1. +1 −1  create.inc.php
  2. +12 −6 edit.inc.php
View
2  create.inc.php
@@ -26,7 +26,7 @@
if (strlen($field["field"]) && isset($types[$field["type"]])) {
$fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
. idf_escape($field["field"]) . process_type($field)
- . ($field["null"] ? "" : " NOT NULL")
+ . ($field["null"] ? " NULL" : " NOT NULL") // NULL for timestamp
. ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
. " COMMENT '" . $mysql->escape_string($field["comment"]) . "'"
. (strlen($_GET["create"]) && !strlen($field["orig"]) ? $after : "")
View
18 edit.inc.php
@@ -1,9 +1,9 @@
<?php
$where = where();
-$fields = array();
-foreach (fields($_GET["edit"]) as $name => $field) {
- if (isset($_GET["default"]) ? !$field["auto_increment"] : isset($field["privileges"][$where ? "update" : "insert"])) {
- $fields[$name] = $field;
+$fields = fields($_GET["edit"]);
+foreach ($fields as $name => $field) {
+ if (isset($_GET["default"]) ? $field["auto_increment"] : !isset($field["privileges"][$where ? "update" : "insert"])) {
+ unset($fields[$name]);
}
}
if ($_POST && !$error) {
@@ -16,11 +16,17 @@
foreach ($fields as $name => $field) {
$val = process_input($name, $field);
if ($val !== false) {
- $set[] = idf_escape($name) . (isset($_GET["default"]) ? ($val == "NULL" ? " DROP DEFAULT" : " SET DEFAULT $val") : " = $val");
+ if (!isset($_GET["default"])) {
+ $set[] = idf_escape($name) . " = $val";
+ } elseif ($field["type"] == "timestamp") {
+ $set[] = " MODIFY " . idf_escape($name) . " timestamp" . ($field["null"] ? " NULL" : "") . " DEFAULT $val"; //! ON UPDATE
+ } else {
+ $set[] = " ALTER " . idf_escape($name) . ($val == "NULL" ? " DROP DEFAULT" : " SET DEFAULT $val");
+ }
}
}
if (isset($_GET["default"])) {
- $query = "ALTER TABLE " . idf_escape($_GET["edit"]) . " ALTER " . implode(", ALTER ", $set);
+ $query = "ALTER TABLE " . idf_escape($_GET["edit"]) . implode(",", $set);
$message = lang('Default values has been set.');
} elseif ($where) {
$query = "UPDATE " . idf_escape($_GET["edit"]) . " SET " . implode(", ", $set) . " WHERE " . implode(" AND ", $where) . " LIMIT 1";
Please sign in to comment.
Something went wrong with that request. Please try again.