]> git.joonet.de Git - adminer.git/commitdiff
Auto_increment value
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 19 Jul 2007 14:33:24 +0000 (14:33 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 19 Jul 2007 14:33:24 +0000 (14:33 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@225 7c3ca157-0c34-0410-bff1-cbf682f78f5c

create.inc.php
editing.inc.php

index 9efcbb6ba3b204fec9331be212a6ca512665907c..e670df73d94d512accb26da4317091e2565641b8 100644 (file)
@@ -5,10 +5,10 @@ if ($_POST && !$error && !$_POST["add"]) {
                $message = lang('Table has been dropped.');
        } else {
                $auto_increment_index = " PRIMARY KEY";
-               if (strlen($_GET["create"]) && strlen($_POST["fields"][$_POST["auto_increment"]]["orig"])) {
+               if (strlen($_GET["create"]) && strlen($_POST["fields"][$_POST["auto_increment_col"]]["orig"])) {
                        foreach (indexes($_GET["create"]) as $index) {
                                foreach ($index["columns"] as $column) {
-                                       if ($column === $_POST["fields"][$_POST["auto_increment"]]["orig"]) {
+                                       if ($column === $_POST["fields"][$_POST["auto_increment_col"]]["orig"]) {
                                                $auto_increment_index = "";
                                                break 2;
                                        }
@@ -27,7 +27,7 @@ if ($_POST && !$error && !$_POST["add"]) {
                                $fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
                                        . idf_escape($field["field"]) . process_type($field)
                                        . ($field["null"] ? "" : " NOT NULL")
-                                       . ($key == $_POST["auto_increment"] ? " AUTO_INCREMENT$auto_increment_index" : "")
+                                       . ($key == $_POST["auto_increment_col"] ? " AUTO_INCREMENT$auto_increment_index" : "")
                                        . " COMMENT '" . $mysql->escape_string($field["comment"]) . "'"
                                        . (strlen($_GET["create"]) && !strlen($field["orig"]) ? $after : "")
                                ;
@@ -38,6 +38,7 @@ if ($_POST && !$error && !$_POST["add"]) {
                }
                $status = ($_POST["Engine"] ? " ENGINE='" . $mysql->escape_string($_POST["Engine"]) . "'" : "")
                        . ($_POST["Collation"] ? " COLLATE '" . $mysql->escape_string($_POST["Collation"]) . "'" : "")
+                       . (strlen($_POST["Auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["Auto_increment"]) : "")
                        . " COMMENT='" . $mysql->escape_string($_POST["Comment"]) . "'"
                ;
                if (strlen($_GET["create"])) {
@@ -73,8 +74,8 @@ if ($_POST) {
        } else {
                array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
        }
-       if ($row["auto_increment"]) {
-               $row["fields"][$row["auto_increment"] - 1]["auto_increment"] = true;
+       if ($row["auto_increment_col"]) {
+               $row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true;
        }
 } elseif (strlen($_GET["create"])) {
        $row = table_status($_GET["create"]);
@@ -94,14 +95,15 @@ $collations = collations();
 <?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo htmlspecialchars($row["name"]); ?>" />
 <select name="Engine"><option value="">(<?php echo lang('engine'); ?>)</option><?php echo optionlist($engines, $row["Engine"]); ?></select>
 <select name="Collation"><option value="">(<?php echo lang('collation'); ?>)</option><?php echo optionlist($collations, $row["Collation"]); ?></select>
-<?php //! $row["Auto_increment"] ?>
 <input type="submit" value="<?php echo lang('Save'); ?>" />
 </p>
 <table border="0" cellspacing="0" cellpadding="2">
 <?php $column_comments = edit_fields($row["fields"], $collations); ?>
 </table>
 <?php echo type_change(count($row["fields"])); ?>
-<p><?php echo lang('Comment'); ?>: <input name="Comment" value="<?php echo htmlspecialchars($row["Comment"]); ?>" maxlength="60" />
+<p>
+<?php echo lang('Auto Increment'); ?>: <input name="Auto_increment" size="4" value="<?php echo intval($row["Auto_increment"]); ?>" />
+<?php echo lang('Comment'); ?>: <input name="Comment" value="<?php echo htmlspecialchars($row["Comment"]); ?>" maxlength="60" />
 <script type="text/javascript">
 document.write('<label for="column_comments"><input type="checkbox" id="column_comments"<?php if ($column_comments) { ?> checked="checked"<?php } ?> onclick="column_comments_click(this.checked);" /><?php echo lang('Show column comments'); ?></label>');
 function column_comments_click(checked) {
index fe1eb17970ac37acdbe2123884976f7c4f1ecc91..b772ca10ffe9ae369676e519f9ba54260bc2f243 100644 (file)
@@ -88,7 +88,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
 <td><?php echo lang('Options'); ?></td>
 <?php if ($type == "TABLE") { ?>
 <td><?php echo lang('NULL'); ?></td>
-<td><input type="radio" name="auto_increment" value="" /><?php echo lang('Auto Increment'); ?></td>
+<td><input type="radio" name="auto_increment_col" value="" /><?php echo lang('Auto Increment'); ?></td>
 <td><?php echo lang('Comment'); ?></td>
 <?php } ?>
 <td><input type="submit" name="add[0]" value="<?php echo lang('Add next'); ?>" /></td>
@@ -104,7 +104,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
 <?php edit_type("fields[$i]", $field, $collations); ?>
 <?php if ($type == "TABLE") { ?>
 <td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?> /></td>
-<td><input type="radio" name="auto_increment" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
+<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
 <td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
 <?php } ?>
 <td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /></td>
@@ -128,7 +128,7 @@ function add_row(button) {
        row.parentNode.insertBefore(row.cloneNode(true), row);
        var tags = row.getElementsByTagName('*');
        for (var i=0; i < tags.length; i++) {
-               if (tags[i].name == 'auto_increment') {
+               if (tags[i].name == 'auto_increment_col') {
                        tags[i].value = x;
                } else if (tags[i].name) {
                        tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);