fix logger for SQL commands
This commit is contained in:
parent
b8bea7fc56
commit
4cfe6263d9
|
@ -197,6 +197,15 @@ focus(document.getElementById('username'));
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Query printed in SQL command before execution
|
||||||
|
* @param string query to be executed
|
||||||
|
* @return string escaped query to be printed
|
||||||
|
*/
|
||||||
|
function sqlCommandQuery($query)
|
||||||
|
{
|
||||||
|
return shorten_utf8(trim($query), 1000);
|
||||||
|
}
|
||||||
|
|
||||||
/** Description of a row in a table
|
/** Description of a row in a table
|
||||||
* @param string
|
* @param string
|
||||||
* @return string SQL expression, empty string for no description
|
* @return string SQL expression, empty string for no description
|
||||||
|
|
|
@ -93,7 +93,7 @@ if (!$error && $_POST) {
|
||||||
$empty = false;
|
$empty = false;
|
||||||
$q = substr($query, 0, $pos);
|
$q = substr($query, 0, $pos);
|
||||||
$commands++;
|
$commands++;
|
||||||
$print = "<pre id='sql-$commands'><code class='jush-$jush'>" . shorten_utf8(trim($q), 1000) . "</code></pre>\n";
|
$print = "<pre id='sql-$commands'><code class='jush-$jush'>" . $adminer->sqlCommandQuery($q) . "</code></pre>\n";
|
||||||
if ($jush == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) {
|
if ($jush == "sqlite" && preg_match("~^$space*+ATTACH\\b~i", $q, $match)) {
|
||||||
// PHP doesn't support setting SQLITE_LIMIT_ATTACHED
|
// PHP doesn't support setting SQLITE_LIMIT_ATTACHED
|
||||||
echo $print;
|
echo $print;
|
||||||
|
|
|
@ -177,6 +177,11 @@ class AdminerPlugin extends Adminer {
|
||||||
return $this->_applyPlugin(__FUNCTION__, $args);
|
return $this->_applyPlugin(__FUNCTION__, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sqlCommandQuery($query) {
|
||||||
|
$args = func_get_args();
|
||||||
|
return $this->_applyPlugin(__FUNCTION__, $args);
|
||||||
|
}
|
||||||
|
|
||||||
function rowDescription($table) {
|
function rowDescription($table) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return $this->_applyPlugin(__FUNCTION__, $args);
|
return $this->_applyPlugin(__FUNCTION__, $args);
|
||||||
|
|
|
@ -18,6 +18,14 @@ class AdminerSqlLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
function messageQuery($query, $time) {
|
function messageQuery($query, $time) {
|
||||||
|
$this->_log($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sqlCommandQuery($query) {
|
||||||
|
$this->_log($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _log($query) {
|
||||||
if ($this->filename == "") {
|
if ($this->filename == "") {
|
||||||
$adminer = adminer();
|
$adminer = adminer();
|
||||||
$this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions
|
$this->filename = $adminer->database() . ".sql"; // no database goes to ".sql" to avoid collisions
|
||||||
|
|
Loading…
Reference in a new issue