]> git.joonet.de Git - adminer.git/commitdiff
Log to "$database.sql" by default
authorJakub Vrana <jakub@vrana.cz>
Wed, 10 Aug 2011 16:10:23 +0000 (18:10 +0200)
committerJakub Vrana <jakub@vrana.cz>
Wed, 10 Aug 2011 16:10:23 +0000 (18:10 +0200)
adminer/include/functions.inc.php
plugins/sql-log.php

index fec5ce40992eebb21980947013ba29d3dee6ab4f..04b79888b010021e9498c36ef5144444e372fa60 100644 (file)
@@ -8,6 +8,14 @@ function connection() {
        return $connection;
 }
 
+/** Get Adminer object
+* @return Adminer
+*/
+function adminer() {
+       global $adminer;
+       return $adminer;
+}
+
 /** Unescape database identifier
 * @param string text inside ``
 * @return string
index 6310a73fbc556361d111bc33c1b408d8af072ed3..c61e482ac3aa6dc691ae58c7753c63747fb8da1e 100644 (file)
@@ -10,13 +10,17 @@ class AdminerSqlLog {
        var $filename;
        
        /**
-       * @param string
+       * @param string defaults to "$database.sql"
        */
-       function AdminerSqlLog($filename = "adminer.sql") {
+       function AdminerSqlLog($filename = "") {
                $this->filename = $filename;
        }
        
        function messageQuery($query) {
+               if ($this->filename == "") {
+                       $adminer = adminer();
+                       $this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions
+               }
                $fp = fopen($this->filename, "a");
                flock($fp, LOCK_EX);
                fwrite($fp, $query);