mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-08-30 12:45:32 +08:00
Connection类的debug方法改进,增加第二个参数,改进数据库驱动的获取表信息的sql记录
This commit is contained in:
@@ -738,9 +738,10 @@ abstract class Connection
|
||||
* 数据库调试 记录当前SQL及分析性能
|
||||
* @access protected
|
||||
* @param boolean $start 调试开始标记 true 开始 false 结束
|
||||
* @param string $sql 执行的SQL语句 留空自动获取
|
||||
* @return void
|
||||
*/
|
||||
protected function debug($start)
|
||||
protected function debug($start, $sql = '')
|
||||
{
|
||||
if (!empty($this->config['debug'])) {
|
||||
// 开启数据库调试模式
|
||||
@@ -750,14 +751,15 @@ abstract class Connection
|
||||
// 记录操作结束时间
|
||||
Debug::remark('queryEndTime', 'time');
|
||||
$runtime = Debug::getRangeTime('queryStartTime', 'queryEndTime');
|
||||
$log = $this->queryStr . ' [ RunTime:' . $runtime . 's ]';
|
||||
$sql = $sql ?: $this->queryStr;
|
||||
$log = $sql . ' [ RunTime:' . $runtime . 's ]';
|
||||
$result = [];
|
||||
// SQL性能分析
|
||||
if ($this->config['sql_explain'] && 0 === stripos(trim($this->queryStr), 'select')) {
|
||||
$result = $this->getExplain($this->queryStr);
|
||||
if ($this->config['sql_explain'] && 0 === stripos(trim($sql), 'select')) {
|
||||
$result = $this->getExplain($sql);
|
||||
}
|
||||
// SQL监听
|
||||
$this->trigger($this->queryStr, $runtime, $result);
|
||||
$this->trigger($sql, $runtime, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user