Export triggers after data
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@706 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
7601e68449
commit
da874a3f5e
|
@ -9,6 +9,21 @@ function tar_file($filename, $contents) {
|
||||||
return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
|
return $return . str_repeat("\0", 512 - strlen($return)) . $contents . str_repeat("\0", 511 - (strlen($contents) + 511) % 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dump_triggers($table, $style) {
|
||||||
|
global $dbh;
|
||||||
|
if ($_POST["format"] != "csv" && $style && $dbh->server_info >= 5) {
|
||||||
|
$result = $dbh->query("SHOW TRIGGERS LIKE '" . $dbh->escape_string(addcslashes($table, "%_")) . "'");
|
||||||
|
if ($result->num_rows) {
|
||||||
|
echo "\nDELIMITER ;;\n";
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
echo "\nCREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . idf_escape($row["Table"]) . " FOR EACH ROW\n$row[Statement];;\n";
|
||||||
|
}
|
||||||
|
echo "\nDELIMITER ;\n";
|
||||||
|
}
|
||||||
|
$result->free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST) {
|
if ($_POST) {
|
||||||
$ext = dump_headers((strlen($_GET["dump"]) ? $_GET["dump"] : $_GET["db"]), (!strlen($_GET["db"]) || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
|
$ext = dump_headers((strlen($_GET["dump"]) ? $_GET["dump"] : $_GET["db"]), (!strlen($_GET["db"]) || count((array) $_POST["tables"] + (array) $_POST["data"]) > 1));
|
||||||
if ($_POST["format"] != "csv") {
|
if ($_POST["format"] != "csv") {
|
||||||
|
@ -66,6 +81,9 @@ if ($_POST) {
|
||||||
if ($data) {
|
if ($data) {
|
||||||
dump_data($row["Name"], $_POST["data_style"]);
|
dump_data($row["Name"], $_POST["data_style"]);
|
||||||
}
|
}
|
||||||
|
if ($table) {
|
||||||
|
dump_triggers($row["Name"], $_POST["table_style"]);
|
||||||
|
}
|
||||||
if ($ext == "tar") {
|
if ($ext == "tar") {
|
||||||
echo tar_file((strlen($_GET["db"]) ? "" : "$db/") . "$row[Name].csv", ob_get_clean());
|
echo tar_file((strlen($_GET["db"]) ? "" : "$db/") . "$row[Name].csv", ob_get_clean());
|
||||||
} elseif ($_POST["format"] != "csv") {
|
} elseif ($_POST["format"] != "csv") {
|
||||||
|
|
|
@ -101,18 +101,6 @@ DROP PROCEDURE adminer_alter;
|
||||||
<?php
|
<?php
|
||||||
//! indexes
|
//! indexes
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($dbh->server_info >= 5) {
|
|
||||||
$result = $dbh->query("SHOW TRIGGERS LIKE '" . $dbh->escape_string(addcslashes($table, "%_")) . "'");
|
|
||||||
if ($result->num_rows) {
|
|
||||||
echo "DELIMITER ;;\n\n";
|
|
||||||
while ($row = $result->fetch_assoc()) {
|
|
||||||
echo "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . idf_escape($row["Table"]) . " FOR EACH ROW $row[Statement];;\n\n";
|
|
||||||
}
|
|
||||||
echo "DELIMITER ;\n\n";
|
|
||||||
}
|
|
||||||
$result->free();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue