DBA: Possibility to log the database speed
This commit is contained in:
parent
db2f0f7919
commit
47c48aa438
2 changed files with 17 additions and 4 deletions
|
@ -71,22 +71,32 @@ class dba {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function q($sql) {
|
public function q($sql) {
|
||||||
|
global $a;
|
||||||
|
|
||||||
if((! $this->db) || (! $this->connected))
|
if((! $this->db) || (! $this->connected))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
|
|
||||||
//if (get_config("system", "db_log") != "")
|
if ($a->config["system"]["db_log"] != "")
|
||||||
// @file_put_contents(get_config("system", "db_log"), datetime_convert().':'.session_id(). ' Start '.$sql."\n", FILE_APPEND);
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
if($this->mysqli)
|
if($this->mysqli)
|
||||||
$result = @$this->db->query($sql);
|
$result = @$this->db->query($sql);
|
||||||
else
|
else
|
||||||
$result = @mysql_query($sql,$this->db);
|
$result = @mysql_query($sql,$this->db);
|
||||||
|
|
||||||
//if (get_config("system", "db_log") != "")
|
if ($a->config["system"]["db_log"] != "") {
|
||||||
// @file_put_contents(get_config("system", "db_log"), datetime_convert().':'.session_id(). ' Stop '."\n", FILE_APPEND);
|
$stamp2 = microtime(true);
|
||||||
|
$duration = round($stamp2-$stamp1, 3);
|
||||||
|
if ($duration > $a->config["system"]["db_loglimit"]) {
|
||||||
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
@file_put_contents($a->config["system"]["db_log"], $duration."\t".
|
||||||
|
basename($backtrace[1]["file"])."\t".
|
||||||
|
$backtrace[1]["line"]."\t".$backtrace[2]["function"]."\t".
|
||||||
|
substr($sql, 0, 2000)."\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($this->mysqli) {
|
if($this->mysqli) {
|
||||||
if($this->db->errno)
|
if($this->db->errno)
|
||||||
|
|
|
@ -795,6 +795,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
// Picture addresses can contain special characters
|
||||||
|
$s = htmlspecialchars_decode($s);
|
||||||
|
|
||||||
$matches = null;
|
$matches = null;
|
||||||
$c = preg_match_all('/\[img\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
|
$c = preg_match_all('/\[img\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
|
||||||
if($c) {
|
if($c) {
|
||||||
|
|
Loading…
Reference in a new issue