Revert drop removal (r887, r1195)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1336 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
254ba4a134
commit
5d89dc60c8
|
@ -16,83 +16,87 @@ if ($TABLE != "") {
|
|||
}
|
||||
|
||||
if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"] && !$_POST["up"] && !$_POST["down"]) {
|
||||
$auto_increment_index = " PRIMARY KEY";
|
||||
// don't overwrite primary key by auto_increment
|
||||
if ($TABLE != "" && $_POST["auto_increment_col"]) {
|
||||
foreach (indexes($TABLE) as $index) {
|
||||
if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
|
||||
$auto_increment_index = "";
|
||||
break;
|
||||
}
|
||||
if ($index["type"] == "PRIMARY") {
|
||||
$auto_increment_index = " UNIQUE";
|
||||
}
|
||||
}
|
||||
}
|
||||
$fields = "";
|
||||
ksort($_POST["fields"]);
|
||||
$orig_field = reset($orig_fields);
|
||||
$after = "FIRST";
|
||||
foreach ($_POST["fields"] as $key => $field) {
|
||||
$type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
|
||||
if ($field["field"] != "") {
|
||||
if ($type_field) {
|
||||
$default = eregi_replace(" *on update CURRENT_TIMESTAMP", "", $field["default"]);
|
||||
if ($default != $field["default"]) { // preg_replace $count is available since PHP 5.1.0
|
||||
$field["on_update"] = "CURRENT_TIMESTAMP";
|
||||
$field["default"] = $default;
|
||||
}
|
||||
if (!$field["has_default"]) {
|
||||
$field["default"] = null;
|
||||
}
|
||||
$process_field = process_field($field, $type_field);
|
||||
$auto_increment = ($key == $_POST["auto_increment_col"]);
|
||||
if ($process_field != process_field($orig_field, $orig_field) || $orig_field["auto_increment"] != $auto_increment) {
|
||||
$fields .= "\n" . ($TABLE != "" ? ($field["orig"] != "" ? "CHANGE " . idf_escape($field["orig"]) : "ADD") : " ")
|
||||
. " $process_field"
|
||||
. ($auto_increment ? " AUTO_INCREMENT$auto_increment_index" : "")
|
||||
. ($TABLE != "" ? " $after" : "") . ","
|
||||
;
|
||||
}
|
||||
if (!isset($types[$field["type"]])) {
|
||||
$fields .= ($TABLE != "" ? "\nADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . "),";
|
||||
}
|
||||
}
|
||||
$after = "AFTER " . idf_escape($field["field"]);
|
||||
//! drop and create foreign keys with renamed columns
|
||||
} elseif ($field["orig"] != "") {
|
||||
$fields .= "\nDROP " . idf_escape($field["orig"]) . ",";
|
||||
}
|
||||
if ($field["orig"] != "") {
|
||||
$orig_field = next($orig_fields);
|
||||
}
|
||||
}
|
||||
$status = "COMMENT=" . $connection->quote($_POST["Comment"])
|
||||
. ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
|
||||
. ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
|
||||
. ($_POST["Auto_increment"] != "" ? " AUTO_INCREMENT=" . preg_replace('~[^0-9]+~', '', $_POST["Auto_increment"]) : "")
|
||||
;
|
||||
if (in_array($_POST["partition_by"], $partition_by)) {
|
||||
$partitions = array();
|
||||
if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
|
||||
foreach (array_filter($_POST["partition_names"]) as $key => $val) {
|
||||
$value = $_POST["partition_values"][$key];
|
||||
$partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
|
||||
}
|
||||
}
|
||||
$status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
|
||||
? " (" . implode(",", $partitions) . "\n)"
|
||||
: ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
|
||||
);
|
||||
} elseif ($connection->server_info >= 5.1 && $TABLE != "") {
|
||||
$status .= "\nREMOVE PARTITIONING";
|
||||
}
|
||||
$location = ME . "table=" . urlencode($_POST["name"]);
|
||||
if ($TABLE != "") {
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE) . "$fields\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
|
||||
if ($_POST["drop"]) {
|
||||
query_redirect("DROP TABLE " . idf_escape($_GET["create"]), substr(ME, 0, -1), lang('Table has been dropped.'));
|
||||
} else {
|
||||
cookie("adminer_engine", $_POST["Engine"]);
|
||||
query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . substr($fields, 0, -1) . "\n) $status", $location, lang('Table has been created.'));
|
||||
$auto_increment_index = " PRIMARY KEY";
|
||||
// don't overwrite primary key by auto_increment
|
||||
if ($TABLE != "" && $_POST["auto_increment_col"]) {
|
||||
foreach (indexes($TABLE) as $index) {
|
||||
if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) {
|
||||
$auto_increment_index = "";
|
||||
break;
|
||||
}
|
||||
if ($index["type"] == "PRIMARY") {
|
||||
$auto_increment_index = " UNIQUE";
|
||||
}
|
||||
}
|
||||
}
|
||||
$fields = "";
|
||||
ksort($_POST["fields"]);
|
||||
$orig_field = reset($orig_fields);
|
||||
$after = "FIRST";
|
||||
foreach ($_POST["fields"] as $key => $field) {
|
||||
$type_field = (isset($types[$field["type"]]) ? $field : $referencable_primary[$foreign_keys[$field["type"]]]);
|
||||
if ($field["field"] != "") {
|
||||
if ($type_field) {
|
||||
$default = eregi_replace(" *on update CURRENT_TIMESTAMP", "", $field["default"]);
|
||||
if ($default != $field["default"]) { // preg_replace $count is available since PHP 5.1.0
|
||||
$field["on_update"] = "CURRENT_TIMESTAMP";
|
||||
$field["default"] = $default;
|
||||
}
|
||||
if (!$field["has_default"]) {
|
||||
$field["default"] = null;
|
||||
}
|
||||
$process_field = process_field($field, $type_field);
|
||||
$auto_increment = ($key == $_POST["auto_increment_col"]);
|
||||
if ($process_field != process_field($orig_field, $orig_field) || $orig_field["auto_increment"] != $auto_increment) {
|
||||
$fields .= "\n" . ($TABLE != "" ? ($field["orig"] != "" ? "CHANGE " . idf_escape($field["orig"]) : "ADD") : " ")
|
||||
. " $process_field"
|
||||
. ($auto_increment ? " AUTO_INCREMENT$auto_increment_index" : "")
|
||||
. ($TABLE != "" ? " $after" : "") . ","
|
||||
;
|
||||
}
|
||||
if (!isset($types[$field["type"]])) {
|
||||
$fields .= ($TABLE != "" ? "\nADD" : "") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . idf_escape($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . "),";
|
||||
}
|
||||
}
|
||||
$after = "AFTER " . idf_escape($field["field"]);
|
||||
//! drop and create foreign keys with renamed columns
|
||||
} elseif ($field["orig"] != "") {
|
||||
$fields .= "\nDROP " . idf_escape($field["orig"]) . ",";
|
||||
}
|
||||
if ($field["orig"] != "") {
|
||||
$orig_field = next($orig_fields);
|
||||
}
|
||||
}
|
||||
$status = "COMMENT=" . $connection->quote($_POST["Comment"])
|
||||
. ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
|
||||
. ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
|
||||
. ($_POST["Auto_increment"] != "" ? " AUTO_INCREMENT=" . preg_replace('~[^0-9]+~', '', $_POST["Auto_increment"]) : "")
|
||||
;
|
||||
if (in_array($_POST["partition_by"], $partition_by)) {
|
||||
$partitions = array();
|
||||
if ($_POST["partition_by"] == 'RANGE' || $_POST["partition_by"] == 'LIST') {
|
||||
foreach (array_filter($_POST["partition_names"]) as $key => $val) {
|
||||
$value = $_POST["partition_values"][$key];
|
||||
$partitions[] = "\nPARTITION " . idf_escape($val) . " VALUES " . ($_POST["partition_by"] == 'RANGE' ? "LESS THAN" : "IN") . ($value != "" ? " ($value)" : " MAXVALUE"); //! SQL injection
|
||||
}
|
||||
}
|
||||
$status .= "\nPARTITION BY $_POST[partition_by]($_POST[partition])" . ($partitions // $_POST["partition"] can be expression, not only column
|
||||
? " (" . implode(",", $partitions) . "\n)"
|
||||
: ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
|
||||
);
|
||||
} elseif ($connection->server_info >= 5.1 && $TABLE != "") {
|
||||
$status .= "\nREMOVE PARTITIONING";
|
||||
}
|
||||
$location = ME . "table=" . urlencode($_POST["name"]);
|
||||
if ($TABLE != "") {
|
||||
query_redirect("ALTER TABLE " . idf_escape($TABLE) . "$fields\nRENAME TO " . idf_escape($_POST["name"]) . ",\n$status", $location, lang('Table has been altered.'));
|
||||
} else {
|
||||
cookie("adminer_engine", $_POST["Engine"]);
|
||||
query_redirect("CREATE TABLE " . idf_escape($_POST["name"]) . " (" . substr($fields, 0, -1) . "\n) $status", $location, lang('Table has been created.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,6 +178,7 @@ document.write('<label><input type="checkbox"<?php if ($column_comments) { ?> ch
|
|||
<p>
|
||||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
<?php if (strlen($_GET["create"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo $confirm; ?>><?php } ?>
|
||||
<?php
|
||||
if ($connection->server_info >= 5.1) {
|
||||
$partition_table = ereg('RANGE|LIST', $row["partition_by"]);
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<?php
|
||||
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
|
||||
if (DB !== $_POST["name"]) {
|
||||
restart_session();
|
||||
if ($_POST["drop"]) {
|
||||
unset($_SESSION["databases"][$_GET["server"]]);
|
||||
query_redirect("DROP DATABASE " . idf_escape(DB), remove_from_uri("db|database"), lang('Database has been dropped.'));
|
||||
} elseif (DB !== $_POST["name"]) {
|
||||
// create or rename database
|
||||
restart_session();
|
||||
unset($_SESSION["databases"][$_GET["server"]]); // clear cache
|
||||
$dbs = explode("\n", str_replace("\r", "", $_POST["name"]));
|
||||
$failed = false;
|
||||
|
@ -70,7 +73,9 @@ if ($_POST) {
|
|||
<input type="hidden" name="token" value="<?php echo $token; ?>">
|
||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||
<?php
|
||||
if (!$_POST["add_x"] && $_GET["db"] == "") {
|
||||
if (strlen(DB)) {
|
||||
echo "<input type='submit' name='drop' value='" . lang('Drop') . "'$confirm>\n";
|
||||
} elseif (!$_POST["add_x"] && $_GET["db"] == "") {
|
||||
echo "<input type='image' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Vybrat databázi',
|
||||
'Invalid database.' => 'Nesprávná databáze.',
|
||||
'Create new database' => 'Vytvořit novou databázi',
|
||||
'Table has been dropped.' => 'Tabulka byla odstraněna.',
|
||||
'Table has been altered.' => 'Tabulka byla změněna.',
|
||||
'Table has been created.' => 'Tabulka byla vytvořena.',
|
||||
'Alter table' => 'Pozměnit tabulku',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Datenbank auswählen',
|
||||
'Invalid database.' => 'Datenbank ungültig.',
|
||||
'Create new database' => 'Neue Datenbank',
|
||||
'Table has been dropped.' => 'Tabelle entfernt.',
|
||||
'Table has been altered.' => 'Tabelle geändert.',
|
||||
'Table has been created.' => 'Tabelle erstellt.',
|
||||
'Alter table' => 'Tabelle ändern',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Seleccionar Base de datos',
|
||||
'Invalid database.' => 'Base de datos inválida.',
|
||||
'Create new database' => 'Nueva Base de datos',
|
||||
'Table has been dropped.' => 'Tabla eliminada.',
|
||||
'Table has been altered.' => 'Tabla modificada.',
|
||||
'Table has been created.' => 'Tabla creada.',
|
||||
'Alter table' => 'Modificar Estructura',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Vali andmebaas',
|
||||
'Invalid database.' => 'Tundmatu andmebaas.',
|
||||
'Create new database' => 'Loo uus andmebaas',
|
||||
'Table has been dropped.' => 'Tabel on edukalt kustutatud.',
|
||||
'Table has been altered.' => 'Tabeli andmed on edukalt muudetud.',
|
||||
'Table has been created.' => 'Tabel on edukalt loodud.',
|
||||
'Alter table' => 'Muuda tabeli struktuuri',
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
$translations = array(
|
||||
'Login' => 'Authentification',
|
||||
'Logout successful.' => 'Aurevoir!',
|
||||
'Invalid credentials.' => 'Authentification échouée',
|
||||
'Invalid credentials.' => 'Authentification échouée.',
|
||||
'Server' => 'Serveur',
|
||||
'Username' => 'Utilisateur',
|
||||
'Password' => 'Mot de passe',
|
||||
'Select database' => 'Selectionner la base de donnée',
|
||||
'Invalid database.' => 'Base de donnée invalide',
|
||||
'Invalid database.' => 'Base de donnée invalide.',
|
||||
'Create new database' => 'Créer une base de donnée',
|
||||
'Table has been altered.' => 'Table modifiée',
|
||||
'Table has been dropped.' => 'Table effacée.',
|
||||
'Table has been altered.' => 'Table modifiée.',
|
||||
'Table has been created.' => 'Table créée.',
|
||||
'Alter table' => 'Modifier la table',
|
||||
'Create table' => 'Créer une table',
|
||||
|
@ -57,7 +58,7 @@ $translations = array(
|
|||
'Sort' => 'Ordonner',
|
||||
'descending' => 'décroissant',
|
||||
'Limit' => 'Limit',
|
||||
'No rows.' => 'Aucun résultat',
|
||||
'No rows.' => 'Aucun résultat.',
|
||||
'Action' => 'Action',
|
||||
'edit' => 'modifier',
|
||||
'Page' => 'Page',
|
||||
|
@ -170,9 +171,9 @@ $translations = array(
|
|||
'At given time' => 'À un moment précis',
|
||||
'Save and continue edit' => 'Sauvegarder et continuer l\'édition',
|
||||
'original' => 'original',
|
||||
'Tables have been truncated.' => 'Les tables ont été tronquées',
|
||||
'Tables have been moved.' => 'Les tables ont été déplacées',
|
||||
'Tables have been dropped.' => 'Les tables ont été effacées',
|
||||
'Tables have been truncated.' => 'Les tables ont été tronquées.',
|
||||
'Tables have been moved.' => 'Les tables ont été déplacées.',
|
||||
'Tables have been dropped.' => 'Les tables ont été effacées.',
|
||||
'Tables and views' => 'Tables et vues',
|
||||
'Engine' => 'Moteur',
|
||||
'Collation' => 'Collation',
|
||||
|
@ -191,12 +192,12 @@ $translations = array(
|
|||
'%d item(s) have been affected.' => array('%d élément ont été modifié.', '%d éléments ont été modifié.'),
|
||||
'whole result' => 'résultat entier',
|
||||
'Clone' => 'Cloner',
|
||||
'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Le nombre de champs maximum est dépassé. Veuillez augmenter %s et %s',
|
||||
'Maximum number of allowed fields exceeded. Please increase %s and %s.' => 'Le nombre de champs maximum est dépassé. Veuillez augmenter %s et %s.',
|
||||
'Partition by' => 'Partitionné par',
|
||||
'Partitions' => 'Partitions',
|
||||
'Partition name' => 'Nom de la partition',
|
||||
'Values' => 'Valeurs',
|
||||
'%d row(s) have been imported.' => array('%d ligne a été importé','%d lignes ont été importé'),
|
||||
'%d row(s) have been imported.' => array('%d ligne a été importé.','%d lignes ont été importé.'),
|
||||
'Show structure' => 'Structure de la table',
|
||||
'(anywhere)' => '(n\'importe où)',
|
||||
'CSV Import' => 'Importation CVS',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Seleziona database',
|
||||
'Invalid database.' => 'Database non valido.',
|
||||
'Create new database' => 'Crea nuovo database',
|
||||
'Table has been dropped.' => 'Tabella eliminata.',
|
||||
'Table has been altered.' => 'Tabella modificata.',
|
||||
'Table has been created.' => 'Tabella creata.',
|
||||
'Alter table' => 'Modifica tabella',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Database selecteren',
|
||||
'Invalid database.' => 'Ongeldige database.',
|
||||
'Create new database' => 'Nieuwe database',
|
||||
'Table has been dropped.' => 'Tabel verwijderd.',
|
||||
'Table has been altered.' => 'Tabel aangepast.',
|
||||
'Table has been created.' => 'Tabel aangemaakt.',
|
||||
'Alter table' => 'Tabel aanpassen',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Выбрать базу данных',
|
||||
'Invalid database.' => 'Плохая база данных.',
|
||||
'Create new database' => 'Создать новую базу данных',
|
||||
'Table has been dropped.' => 'Таблица была удалена.',
|
||||
'Table has been altered.' => 'Таблица была изменена.',
|
||||
'Table has been created.' => 'Таблица была создана.',
|
||||
'Alter table' => 'Изменить таблицу',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => 'Vybrať databázu',
|
||||
'Invalid database.' => 'Nesprávna databáza.',
|
||||
'Create new database' => 'Vytvoriť novú databázu',
|
||||
'Table has been dropped.' => 'Tabuľka bola odstránená.',
|
||||
'Table has been altered.' => 'Tabuľka bola zmenená.',
|
||||
'Table has been created.' => 'Tabuľka bola vytvorená.',
|
||||
'Alter table' => 'Zmeniť tabuľku',
|
||||
|
|
|
@ -9,6 +9,7 @@ $translations = array(
|
|||
'Select database' => '选择数据库',
|
||||
'Invalid database.' => '无效数据库。',
|
||||
'Create new database' => '创建新数据库',
|
||||
'Table has been dropped.' => '已丢弃表。',
|
||||
'Table has been altered.' => '已更改表。',
|
||||
'Table has been created.' => '已创建表。',
|
||||
'Alter table' => '更改表',
|
||||
|
|
Loading…
Reference in a new issue