This commit is contained in:
Roman Kelesidis 2023-10-23 08:52:46 +07:00
parent 1dcfa83a4f
commit 67e625e992
4 changed files with 26 additions and 38 deletions

View File

@ -123,7 +123,7 @@ class sql_db
*/
function connect ()
{
$this->cur_query = 'connect';
$this->cur_query = "connect to: '{$this->cfg['dbhost']}'";
$this->debug('start');
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
@ -401,16 +401,11 @@ class sql_db
if (!SQL_DEBUG) return;
if ($mode == 'start')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG_TRACKER || SQL_LOG_SLOW_QUERIES)
{
$this->sql_starttime = utime();
$this->sql_last_time = 0;
}
}
elseif ($mode == 'end')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG_TRACKER || SQL_LOG_SLOW_QUERIES)
{
$this->sql_last_time = utime() - $this->sql_starttime;
$this->sql_timetotal += $this->sql_last_time;
@ -428,7 +423,6 @@ class sql_db
}
}
}
}
/**
* Trigger error

View File

@ -93,7 +93,7 @@ class sql_db
*/
function connect ()
{
$this->cur_query = ($this->dbg_enabled) ? ($this->cfg['persist'] ? 'p' : '') . "connect to: {$this->cfg['dbhost']}" : 'connect';
$this->cur_query = ($this->dbg_enabled) ? ($this->cfg['persist'] ? 'p' : '') . "connect to: '{$this->cfg['dbhost']}'" : 'connect';
$this->debug('start');
$connect_type = ($this->cfg['persist']) ? 'mysql_pconnect' : 'mysql_connect';
@ -747,11 +747,8 @@ class sql_db
$dbg =& $this->dbg[$id];
if ($mode == 'start')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
{
$this->sql_starttime = utime();
}
if ($this->dbg_enabled)
{
$dbg['sql'] = preg_replace('#^(\s*)(/\*)(.*)(\*/)(\s*)#', '', $this->cur_query);
@ -768,8 +765,6 @@ class sql_db
}
}
else if ($mode == 'stop')
{
if (SQL_CALC_QUERY_TIME || DBG_LOG || SQL_LOG_SLOW_QUERIES)
{
$this->cur_query_time = utime() - $this->sql_starttime;
$this->sql_timetotal += $this->cur_query_time;
@ -779,7 +774,6 @@ class sql_db
{
$this->log_slow_query();
}
}
if ($this->dbg_enabled)
{
$dbg['time'] = utime() - $this->sql_starttime;

View File

@ -47,8 +47,8 @@ function get_sql_log_html ($db_obj, $log_name)
{
$id = "sql_{$i}_". mt_rand();
$sql = short_query($dbg['sql'], true);
$time = sprintf('%.4f', $dbg['time']);
$perc = @sprintf('[%d%%]', round($dbg['time']*100/$db_obj->sql_timetotal));
$time = SQL_CALC_QUERY_TIME ? sprintf('%.4f', $dbg['time']) : '';
$perc = SQL_CALC_QUERY_TIME ? @sprintf('[%d%%]', round($dbg['time']*100/$db_obj->sql_timetotal)) : '';
$info = !empty($dbg['info']) ? $dbg['info'] .' ['. $dbg['src'] .']' : $dbg['src'];
$log .= ''

View File

@ -38,7 +38,7 @@ if ($show_dbg_info)
if (!empty($DBS))
{
$sql_t = $DBS->sql_timetotal;
$sql_time_txt = ($sql_t) ? sprintf('%.3f '.$lang['SEC'].' (%d%%) · ', $sql_t, round($sql_t*100/$gen_time)) : '';
$sql_time_txt = ($sql_t && SQL_CALC_QUERY_TIME) ? sprintf('%.3f '.$lang['SEC'].' (%d%%) · ', $sql_t, round($sql_t*100/$gen_time)) : '';
$num_q = $DBS->num_queries;
$stat .= "  |  {$DBS->get_db_obj()->engine}: {$sql_time_txt}{$num_q} " . $lang['QUERIES'];
}