]> git.joonet.de Git - adminer.git/commitdiff
Print <database> only once
authorJakub Vrana <jakub@vrana.cz>
Thu, 17 Feb 2011 10:41:19 +0000 (11:41 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 17 Feb 2011 10:41:19 +0000 (11:41 +0100)
plugins/dump-xml.php

index 5ef47a1d89f8f776df3416551a7100a915241571..7e8f3dd22d281e865857706e21d9cee85fd8ffb3 100644 (file)
@@ -6,6 +6,7 @@
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
 */
 class AdminerDumpXml {
+       var $_database = false;
        
        function dumpFormat() {
                return array('xml' => 'XML');
@@ -17,9 +18,17 @@ class AdminerDumpXml {
                }
        }
        
+       function _database() {
+               echo "</database>\n";
+       }
+       
        function dumpData($table, $style, $query) {
                if ($_POST["format"] == "xml") {
-                       echo "<database name='" . h(DB) . "'>\n";
+                       if (!$this->_database) {
+                               $this->_database = true;
+                               echo "<database name='" . h(DB) . "'>\n";
+                               register_shutdown_function(array($this, '_database'));
+                       }
                        $connection = connection();
                        $result = $connection->query($query, 1);
                        if ($result) {
@@ -31,7 +40,6 @@ class AdminerDumpXml {
                                        echo "\t</table>\n";
                                }
                        }
-                       echo "</database>\n";
                        return true;
                }
        }