From 71e0db4106fb9e33571f01e3c34748d85b2789a4 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 10 Aug 2011 18:10:23 +0200 Subject: [PATCH] Log to "$database.sql" by default --- adminer/include/functions.inc.php | 8 ++++++++ plugins/sql-log.php | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index fec5ce40..04b79888 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -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 diff --git a/plugins/sql-log.php b/plugins/sql-log.php index 6310a73f..c61e482a 100644 --- a/plugins/sql-log.php +++ b/plugins/sql-log.php @@ -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);