mirror of
https://github.com/vrana/adminer.git
synced 2026-04-14 00:18:09 +02:00
Database abstraction
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@97 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
<?php
|
||||
if ($_POST && !$error) {
|
||||
if ($_POST["drop"]) {
|
||||
if (mysql_query("DROP DATABASE " . idf_escape($_GET["db"]))) {
|
||||
if ($mysql->query("DROP DATABASE " . idf_escape($_GET["db"]))) {
|
||||
redirect(substr(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF), 0, -1), lang('Database has been dropped.'));
|
||||
}
|
||||
} elseif ($_GET["db"] !== $_POST["name"]) {
|
||||
if (mysql_query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . mysql_real_escape_string($_POST["collation"]) . "'" : ""))) {
|
||||
if ($mysql->query("CREATE DATABASE " . idf_escape($_POST["name"]) . ($_POST["collation"] ? " COLLATE '" . $mysql->real_escape_string($_POST["collation"]) . "'" : ""))) {
|
||||
if (!strlen($_GET["db"])) {
|
||||
redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been created.'));
|
||||
}
|
||||
$result = mysql_query("SHOW TABLES");
|
||||
while ($row = mysql_fetch_row($result)) {
|
||||
if (!mysql_query("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) {
|
||||
$result = $mysql->query("SHOW TABLES");
|
||||
while ($row = $result->fetch_row()) {
|
||||
if (!$mysql->query("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
mysql_free_result($result);
|
||||
$result->free();
|
||||
if (!$row) {
|
||||
mysql_query("DROP DATABASE " . idf_escape($_GET["db"]));
|
||||
$mysql->query("DROP DATABASE " . idf_escape($_GET["db"]));
|
||||
redirect(preg_replace('~(\\?)db=[^&]*&|&db=[^&]*~', '\\1', $SELF) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'));
|
||||
}
|
||||
}
|
||||
} elseif (!$_POST["collation"] || mysql_query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . mysql_real_escape_string($_POST["collation"]) . "'")) {
|
||||
} elseif (!$_POST["collation"] || $mysql->query("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE '" . $mysql->real_escape_string($_POST["collation"]) . "'")) {
|
||||
redirect(substr($SELF, 0, -1), ($_POST["collation"] ? lang('Database has been altered.') : null));
|
||||
}
|
||||
$error = mysql_error();
|
||||
$error = $mysql->error;
|
||||
}
|
||||
|
||||
page_header(strlen($_GET["db"]) ? lang('Alter database') . ": " . htmlspecialchars($_GET["db"]) : lang('Create database'));
|
||||
@@ -36,11 +36,11 @@ if ($_POST) {
|
||||
} else {
|
||||
$name = $_GET["db"];
|
||||
$collate = array();
|
||||
if (strlen($_GET["db"]) && ($result = mysql_query("SHOW CREATE DATABASE " . idf_escape($_GET["db"])))) {
|
||||
if (preg_match('~ COLLATE ([^ ]+)~', mysql_result($result, 0, 1), $match)) {
|
||||
if (strlen($_GET["db"]) && ($result = $mysql->query("SHOW CREATE DATABASE " . idf_escape($_GET["db"])))) {
|
||||
if (preg_match('~ COLLATE ([^ ]+)~', $mysql->result($result, 0, 1), $match)) {
|
||||
$collate = $match[1];
|
||||
}
|
||||
mysql_free_result($result);
|
||||
$result->free();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user