Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 34 lines (29 sloc) 0.913 kb
b96facf @vrana New plugin: SQL log
authored
1 <?php
2
9c6a5cd @vrana Comment
authored
3 /** Log all queries to SQL file (manual queries through SQL command are not logged)
091a4d0 @vrana Link to documentation
authored
4 * @link http://www.adminer.org/plugins/#use
b96facf @vrana New plugin: SQL log
authored
5 * @author Jakub Vrana, http://www.vrana.cz/
6 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
8 */
9 class AdminerSqlLog {
7578342 @vrana Comment
authored
10 /** @access protected */
b96facf @vrana New plugin: SQL log
authored
11 var $filename;
12
13 /**
71e0db4 @vrana Log to "$database.sql" by default
authored
14 * @param string defaults to "$database.sql"
b96facf @vrana New plugin: SQL log
authored
15 */
71e0db4 @vrana Log to "$database.sql" by default
authored
16 function AdminerSqlLog($filename = "") {
b96facf @vrana New plugin: SQL log
authored
17 $this->filename = $filename;
18 }
19
20 function messageQuery($query) {
71e0db4 @vrana Log to "$database.sql" by default
authored
21 if ($this->filename == "") {
22 $adminer = adminer();
23 $this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions
24 }
b96facf @vrana New plugin: SQL log
authored
25 $fp = fopen($this->filename, "a");
26 flock($fp, LOCK_EX);
27 fwrite($fp, $query);
28 fwrite($fp, "\n\n");
29 flock($fp, LOCK_UN);
30 fclose($fp);
31 }
32
33 }
Something went wrong with that request. Please try again.