]> git.joonet.de Git - adminer.git/commitdiff
Dump individual tables
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 11 Jul 2007 15:44:35 +0000 (15:44 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Wed, 11 Jul 2007 15:44:35 +0000 (15:44 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@138 7c3ca157-0c34-0410-bff1-cbf682f78f5c

design.inc.php
dump.inc.php

index feae8b250572fc852d64cfd02ddcbc44fd9f29d5..312b150eeea35591aad8ce51f29d451fba5a1860 100644 (file)
@@ -41,7 +41,7 @@ function page_footer($missing = false) {
 <?php if ($missing != "auth") { ?>
 <p>
 <a href="<?php echo htmlspecialchars($SELF); ?>sql="><?php echo lang('SQL command'); ?></a>
-<a href="<?php echo htmlspecialchars($SELF); ?>dump="><?php echo lang('Dump'); ?></a>
+<a href="<?php echo htmlspecialchars($SELF); ?>dump=<?php echo urlencode($_GET["table"]); ?>"><?php echo lang('Dump'); ?></a>
 <a href="<?php echo htmlspecialchars(preg_replace('~db=[^&]*&~', '', $SELF)); ?>logout="><?php echo lang('Logout'); ?></a>
 </p>
 <form action="">
index 80a2c310044267fa34a0672984c733c8a7921b37..e257a415027dc07dea0ef4ade139a09c8e0212ef 100644 (file)
@@ -1,6 +1,25 @@
 <?php
 header("Content-Type: text/plain; charset=utf-8");
 
+function dump_table($table, $data = true) {
+       global $mysql;
+       $result = $mysql->query("SHOW CREATE TABLE " . idf_escape($table));
+       if ($result) {
+               echo $mysql->result($result, 1) . ";\n";
+               $result->free();
+               if ($data) {
+                       $result = $mysql->query("SELECT * FROM " . idf_escape($table)); //! enum and set as numbers
+                       if ($result) {
+                               while ($row = $result->fetch_row()) {
+                                       echo "INSERT INTO " . idf_escape($table) . " VALUES ('" . implode("', '", array_map(array($mysql, 'escape_string'), $row)) . "');\n";
+                               }
+                               $result->free();
+                       }
+               }
+               echo "\n";
+       }
+}
+
 function dump($db) {
        global $mysql;
        static $routines;
@@ -28,21 +47,7 @@ function dump($db) {
        echo "SET CHARACTER SET utf8;\n\n";
        $result = $mysql->query("SHOW TABLE STATUS");
        while ($row = $result->fetch_assoc()) {
-               $result1 = $mysql->query("SHOW CREATE TABLE " . idf_escape($row["Name"]));
-               if ($result1) {
-                       echo $mysql->result($result1, 1) . ";\n";
-                       $result1->free();
-                       if (isset($row["Engine"])) {
-                               $result1 = $mysql->query("SELECT * FROM " . idf_escape($row["Name"])); //! enum and set as numbers
-                               if ($result1) {
-                                       while ($row1 = $result1->fetch_row()) {
-                                               echo "INSERT INTO " . idf_escape($row["Name"]) . " VALUES ('" . implode("', '", array_map(array($mysql, 'escape_string'), $row1)) . "');\n";
-                                       }
-                                       $result1->free();
-                               }
-                       }
-                       echo "\n";
-               }
+               dump_table($row["Name"], isset($row["Engine"]));
        }
        $result->free();
        
@@ -64,9 +69,7 @@ function dump($db) {
        echo "\n\n";
 }
 
-if (strlen($_GET["db"])) {
-       dump($_GET["db"]);
-} else {
+if (!strlen($_GET["db"])) {
        $result = $mysql->query("SHOW DATABASES");
        while ($row = $result->fetch_assoc()) {
                if ($row["Database"] != "information_schema" || $mysql->server_info < 5) {
@@ -76,4 +79,8 @@ if (strlen($_GET["db"])) {
                }
        }
        $result->free();
+} elseif (strlen($_GET["dump"])) {
+       dump_table($_GET["dump"]);
+} else {
+       dump($_GET["db"]);
 }