1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-05 14:17:26 +02:00

Allow exporting SQL in SQL command (fix #1092)

This commit is contained in:
Jakub Vrana
2025-06-18 09:19:15 +02:00
parent 2b52a9b653
commit f24f72ac51
2 changed files with 9 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
## Adminer dev ## Adminer dev
- Allow specifying operator in search anywhere - Allow specifying operator in search anywhere
- Do not order descending in GROUP BY select - Do not order descending in GROUP BY select
- Allow exporting SQL in SQL command (bug #1092)
- Add section links in database overview - Add section links in database overview
- Warn about exceeded max_file_uploads in import - Warn about exceeded max_file_uploads in import
- MySQL 5.0-: Do not load partitioning info in alter table (bug #1099) - MySQL 5.0-: Do not load partitioning info in alter table (bug #1099)

View File

@@ -4,9 +4,13 @@ namespace Adminer;
if (!$error && $_POST["export"]) { if (!$error && $_POST["export"]) {
save_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import"); save_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import");
dump_headers("sql"); dump_headers("sql");
adminer()->dumpTable("", ""); if ($_POST["format"] == "sql") {
adminer()->dumpData("", "table", $_POST["query"]); echo "$_POST[query]\n";
adminer()->dumpFooter(); } else {
adminer()->dumpTable("", "");
adminer()->dumpData("", "table", $_POST["query"]);
adminer()->dumpFooter();
}
exit; exit;
} }
@@ -68,8 +72,6 @@ if (!$error && $_POST) {
$parse = '[\'"' . (JUSH == "sql" ? '`#' : (JUSH == "sqlite" ? '`[' : (JUSH == "mssql" ? '[' : ''))) . ']|/\*|' . $line_comment . '|$' . (JUSH == "pgsql" ? '|\$[^$]*\$' : ''); $parse = '[\'"' . (JUSH == "sql" ? '`#' : (JUSH == "sqlite" ? '`[' : (JUSH == "mssql" ? '[' : ''))) . ']|/\*|' . $line_comment . '|$' . (JUSH == "pgsql" ? '|\$[^$]*\$' : '');
$total_start = microtime(true); $total_start = microtime(true);
$adminer_export = get_settings("adminer_import"); // this doesn't offer SQL export so we match the import/export style at select $adminer_export = get_settings("adminer_import"); // this doesn't offer SQL export so we match the import/export style at select
$dump_format = adminer()->dumpFormat();
unset($dump_format["sql"]);
while ($query != "") { while ($query != "") {
if (!$offset && preg_match("~^$space*+DELIMITER\\s+(\\S+)~i", $query, $match)) { if (!$offset && preg_match("~^$space*+DELIMITER\\s+(\\S+)~i", $query, $match)) {
@@ -174,7 +176,7 @@ if (!$error && $_POST) {
$id = "export-$commands"; $id = "export-$commands";
echo ", <a href='#$id'>" . lang('Export') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") . "<span id='$id' class='hidden'>: " echo ", <a href='#$id'>" . lang('Export') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "") . "<span id='$id' class='hidden'>: "
. html_select("output", adminer()->dumpOutput(), $adminer_export["output"]) . " " . html_select("output", adminer()->dumpOutput(), $adminer_export["output"]) . " "
. html_select("format", $dump_format, $adminer_export["format"]) . html_select("format", adminer()->dumpFormat(), $adminer_export["format"])
. input_hidden("query", $q) . input_hidden("query", $q)
. "<input type='submit' name='export' value='" . lang('Export') . "'>" . input_token() . "</span>\n" . "<input type='submit' name='export' value='" . lang('Export') . "'>" . input_token() . "</span>\n"
. "</form>\n" . "</form>\n"