mirror of
https://github.com/vrana/adminer.git
synced 2026-07-30 10:29:56 +02:00
Alter database
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@450 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
47
dump.inc.php
47
dump.inc.php
@@ -73,10 +73,53 @@ if ($_POST) {
|
||||
}
|
||||
}
|
||||
$result->free();
|
||||
foreach ($views as $view => $style) {
|
||||
dump_table($view, $style);
|
||||
foreach ($views as $view => $style1) {
|
||||
dump_table($view, $style1, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($mysql->server_info >= 5 && $style == "CREATE, ALTER" && $_POST["format"] != "csv") {
|
||||
$query = "SELECT TABLE_NAME, ENGINE, TABLE_COLLATION, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE()";
|
||||
?>
|
||||
DELIMITER ;;
|
||||
CREATE PROCEDURE phpminadmin_drop () BEGIN
|
||||
DECLARE _table_name, _engine, _table_collation varchar(64);
|
||||
DECLARE _table_comment varchar(64);
|
||||
DECLARE done bool DEFAULT 0;
|
||||
DECLARE tables CURSOR FOR <?php echo $query; ?>;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
|
||||
OPEN tables;
|
||||
REPEAT
|
||||
FETCH tables INTO _table_name, _engine, _table_collation, _table_comment;
|
||||
IF NOT done THEN
|
||||
CASE _table_name<?php
|
||||
$result = $mysql->query($query);
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$comment = $mysql->escape_string($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
|
||||
echo "
|
||||
WHEN '" . $mysql->escape_string($row["TABLE_NAME"]) . "' THEN
|
||||
" . (isset($row["ENGINE"]) ? "IF _engine != '$row[ENGINE]' OR _table_collation != '$row[TABLE_COLLATION]' OR _table_comment != '$comment' THEN
|
||||
ALTER TABLE " . idf_escape($row["TABLE_NAME"]) . " ENGINE=$row[ENGINE] COLLATE=$row[TABLE_COLLATION] COMMENT='$comment';
|
||||
END IF" : "BEGIN END") . ";";
|
||||
}
|
||||
$result->free();
|
||||
?>
|
||||
|
||||
ELSE
|
||||
SET @alter_table = CONCAT('DROP TABLE `', REPLACE(_table_name, '`', '``'), '`');
|
||||
PREPARE alter_command FROM @alter_table;
|
||||
EXECUTE alter_command;
|
||||
DROP PREPARE alter_command;
|
||||
END CASE;
|
||||
END IF;
|
||||
UNTIL done END REPEAT;
|
||||
CLOSE tables;
|
||||
END;;
|
||||
DELIMITER ;
|
||||
CALL phpminadmin_drop;
|
||||
DROP PROCEDURE phpminadmin_drop;
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user