Browse Source

DEBUG_LEVEL===TRUE打印SQL执行时间和标签加载时间

tags/6.0.0
tianya 3 years ago
parent
commit
9111864978
3 changed files with 21 additions and 5 deletions
  1. +2
    -2
      src/include/dedesql.class.php
  2. +17
    -2
      src/include/dedesqli.class.php
  3. +2
    -1
      src/include/helpers/channelunit.helper.php

+ 2
- 2
src/include/dedesql.class.php View File

@@ -86,7 +86,7 @@ class DedeSql
}
function SelectDB($dbname)
{
mysql_select_db($dbname);
mysql_select_db($dbname, $this->linkID);
}
//设置SQL里的参数
@@ -134,7 +134,7 @@ class DedeSql
exit();
}
$this->isInit = TRUE;
@mysql_select_db($this->dbName);
@mysql_select_db($this->dbName, $this->linkID);
$mysqlver = explode('.',$this->GetVersion());
$mysqlver = $mysqlver[0].'.'.$mysqlver[1];


+ 17
- 2
src/include/dedesqli.class.php View File

@@ -240,8 +240,12 @@ class DedeSqli
if($this->recordLog) {
$queryTime = ExecTime() - $t1;
$this->RecordLog($queryTime);
//echo $this->queryString."--{$queryTime}<hr />\r\n";
}
if (DEBUG_LEVEL===TRUE) {
$queryTime = ExecTime() - $t1;
echo "<div style='width:98%;margin:1rem auto;color: #155724;background-color: #d4edda;border-color: #c3e6cb;position: relative;padding: .75rem 1.25rem;border: 1px solid transparent;border-radius: .25rem;'>执行SQL:".$this->queryString.",执行时间:<b>{$queryTime}</b></div>\r\n";
}
return $rs;
}
@@ -280,6 +284,10 @@ class DedeSqli
$this->RecordLog($queryTime);
//echo $this->queryString."--{$queryTime}<hr />\r\n";
}
if (DEBUG_LEVEL===TRUE) {
$queryTime = ExecTime() - $t1;
echo "<div style='width:98%;margin:1rem auto;color: #155724;background-color: #d4edda;border-color: #c3e6cb;position: relative;padding: .75rem 1.25rem;border: 1px solid transparent;border-radius: .25rem;'>执行SQL:".$this->queryString.",执行时间:<b>{$queryTime}</b></div>\r\n";
}
return mysqli_affected_rows($this->linkID);
}
@@ -333,6 +341,10 @@ class DedeSqli
$this->RecordLog($queryTime);
//echo $this->queryString."--{$queryTime}<hr />\r\n";
}
if (DEBUG_LEVEL===TRUE) {
$queryTime = ExecTime() - $t1;
echo "<div style='width:98%;margin:1rem auto;color: #155724;background-color: #d4edda;border-color: #c3e6cb;position: relative;padding: .75rem 1.25rem;border: 1px solid transparent;border-radius: .25rem;'>执行SQL:".$this->queryString.",执行时间:<b>{$queryTime}</b></div>\r\n";
}
if($this->result[$id]===FALSE)
{
@@ -349,15 +361,18 @@ class DedeSqli
function GetOne($sql='',$acctype=MYSQLI_ASSOC)
{
global $dsqli;
// $t1 = ExecTime();
if(!$dsqli->isInit)
{
$this->Init($this->pconnect);
}
}
// echo ExecTime() - $t1;
if($dsqli->isClose)
{
$this->Open(FALSE);
$dsqli->isClose = FALSE;
}
if(!empty($sql))
{
if(!preg_match("/LIMIT/i",$sql)) $this->SetQuery(preg_replace("/[,;]$/i", '', trim($sql))." LIMIT 0,1;");


+ 2
- 1
src/include/helpers/channelunit.helper.php View File

@@ -5,6 +5,7 @@
* @version $Id: channelunit.helper.php 1 16:49 2010年7月6日Z tianya $
* @package DedeCMS.Helpers
* @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
* @copyright Copyright (c) 2020, DedeBIZ.COM
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
@@ -558,7 +559,7 @@ function MakeOneTag(&$dtp, &$refObj, $parfield='Y')
$dtp->Assign($tagid,$funcname($ctag,$refObj));
if (DEBUG_LEVEL==TRUE) {
$queryTime = ExecTime() - $ttt1;
echo '标签:'.$tagname.'载入花费时间:'.$queryTime."<br />\r\n";
echo '<div style="color: #856404;background-color: #fff3cd;border-color: #ffeeba;position: relative;padding: .75rem 1.25rem;margin-bottom: 1rem;border: 1px solid transparent;border-radius: .25rem;" class="alert alert-warning" role="alert">标签:'.$tagname.'载入花费时间:'.$queryTime."</div>\r\n";
}
}
}


Loading…
Cancel
Save