]> git.joonet.de Git - adminer.git/commitdiff
Allow exporting SQL in SQL command (fix #1092)
authorJakub Vrana <jakub@vrana.cz>
Wed, 18 Jun 2025 07:19:15 +0000 (09:19 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 18 Jun 2025 07:19:15 +0000 (09:19 +0200)
CHANGELOG.md
adminer/sql.inc.php

index 8fd6492e9c1d1bc86f7d069e5f15d3446fbe122d..168a8959e6cc8097075cb0189b8d736ad2cb17dc 100644 (file)
@@ -1,6 +1,7 @@
 ## Adminer dev
 - Allow specifying operator in search anywhere
 - Do not order descending in GROUP BY select
+- Allow exporting SQL in SQL command (bug #1092)
 - Add section links in database overview
 - Warn about exceeded max_file_uploads in import
 - MySQL 5.0-: Do not load partitioning info in alter table (bug #1099)
index c2908c5396a21187201c8fe453a21d82a08b8860..f774bf102258ea613d719b970c81241eb07a322b 100644 (file)
@@ -4,9 +4,13 @@ namespace Adminer;
 if (!$error && $_POST["export"]) {
        save_settings(array("output" => $_POST["output"], "format" => $_POST["format"]), "adminer_import");
        dump_headers("sql");
-       adminer()->dumpTable("", "");
-       adminer()->dumpData("", "table", $_POST["query"]);
-       adminer()->dumpFooter();
+       if ($_POST["format"] == "sql") {
+               echo "$_POST[query]\n";
+       } else {
+               adminer()->dumpTable("", "");
+               adminer()->dumpData("", "table", $_POST["query"]);
+               adminer()->dumpFooter();
+       }
        exit;
 }
 
@@ -68,8 +72,6 @@ if (!$error && $_POST) {
                $parse = '[\'"' . (JUSH == "sql" ? '`#' : (JUSH == "sqlite" ? '`[' : (JUSH == "mssql" ? '[' : ''))) . ']|/\*|' . $line_comment . '|$' . (JUSH == "pgsql" ? '|\$[^$]*\$' : '');
                $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
-               $dump_format = adminer()->dumpFormat();
-               unset($dump_format["sql"]);
 
                while ($query != "") {
                        if (!$offset && preg_match("~^$space*+DELIMITER\\s+(\\S+)~i", $query, $match)) {
@@ -174,7 +176,7 @@ if (!$error && $_POST) {
                                                                                        $id = "export-$commands";
                                                                                        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("format", $dump_format, $adminer_export["format"])
+                                                                                               . html_select("format", adminer()->dumpFormat(), $adminer_export["format"])
                                                                                                . input_hidden("query", $q)
                                                                                                . "<input type='submit' name='export' value='" . lang('Export') . "'>" . input_token() . "</span>\n"
                                                                                                . "</form>\n"