1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-13 18:14:07 +02:00

Auto_increment value

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@225 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2007-07-19 14:33:24 +00:00
parent 3b9c93fb27
commit 40571431c5
2 changed files with 12 additions and 10 deletions

View File

@@ -5,10 +5,10 @@ if ($_POST && !$error && !$_POST["add"]) {
$message = lang('Table has been dropped.'); $message = lang('Table has been dropped.');
} else { } else {
$auto_increment_index = " PRIMARY KEY"; $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 (indexes($_GET["create"]) as $index) {
foreach ($index["columns"] as $column) { 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 = ""; $auto_increment_index = "";
break 2; break 2;
} }
@@ -27,7 +27,7 @@ if ($_POST && !$error && !$_POST["add"]) {
$fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD ")) $fields[] = (!strlen($_GET["create"]) ? "" : (strlen($field["orig"]) ? "CHANGE " . idf_escape($field["orig"]) . " " : "ADD "))
. idf_escape($field["field"]) . process_type($field) . idf_escape($field["field"]) . process_type($field)
. ($field["null"] ? "" : " NOT NULL") . ($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"]) . "'" . " COMMENT '" . $mysql->escape_string($field["comment"]) . "'"
. (strlen($_GET["create"]) && !strlen($field["orig"]) ? $after : "") . (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"]) . "'" : "") $status = ($_POST["Engine"] ? " ENGINE='" . $mysql->escape_string($_POST["Engine"]) . "'" : "")
. ($_POST["Collation"] ? " COLLATE '" . $mysql->escape_string($_POST["Collation"]) . "'" : "") . ($_POST["Collation"] ? " COLLATE '" . $mysql->escape_string($_POST["Collation"]) . "'" : "")
. (strlen($_POST["Auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["Auto_increment"]) : "")
. " COMMENT='" . $mysql->escape_string($_POST["Comment"]) . "'" . " COMMENT='" . $mysql->escape_string($_POST["Comment"]) . "'"
; ;
if (strlen($_GET["create"])) { if (strlen($_GET["create"])) {
@@ -73,8 +74,8 @@ if ($_POST) {
} else { } else {
array_splice($row["fields"], key($_POST["add"]), 0, array(array())); array_splice($row["fields"], key($_POST["add"]), 0, array(array()));
} }
if ($row["auto_increment"]) { if ($row["auto_increment_col"]) {
$row["fields"][$row["auto_increment"] - 1]["auto_increment"] = true; $row["fields"][$row["auto_increment_col"] - 1]["auto_increment"] = true;
} }
} elseif (strlen($_GET["create"])) { } elseif (strlen($_GET["create"])) {
$row = table_status($_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"]); ?>" /> <?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="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> <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'); ?>" /> <input type="submit" value="<?php echo lang('Save'); ?>" />
</p> </p>
<table border="0" cellspacing="0" cellpadding="2"> <table border="0" cellspacing="0" cellpadding="2">
<?php $column_comments = edit_fields($row["fields"], $collations); ?> <?php $column_comments = edit_fields($row["fields"], $collations); ?>
</table> </table>
<?php echo type_change(count($row["fields"])); ?> <?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"> <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>'); 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) { function column_comments_click(checked) {

View File

@@ -88,7 +88,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
<td><?php echo lang('Options'); ?></td> <td><?php echo lang('Options'); ?></td>
<?php if ($type == "TABLE") { ?> <?php if ($type == "TABLE") { ?>
<td><?php echo lang('NULL'); ?></td> <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> <td><?php echo lang('Comment'); ?></td>
<?php } ?> <?php } ?>
<td><input type="submit" name="add[0]" value="<?php echo lang('Add next'); ?>" /></td> <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 edit_type("fields[$i]", $field, $collations); ?>
<?php if ($type == "TABLE") { ?> <?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="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> <td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
<?php } ?> <?php } ?>
<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" /></td> <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); row.parentNode.insertBefore(row.cloneNode(true), row);
var tags = row.getElementsByTagName('*'); var tags = row.getElementsByTagName('*');
for (var i=0; i < tags.length; i++) { 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; tags[i].value = x;
} else if (tags[i].name) { } else if (tags[i].name) {
tags[i].name = tags[i].name.replace(/([0-9.]+)/, x); tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);