Connection类的数据库连接参数增加sql_explain配置 用于配置是否需要分析SQL性能 默认关闭

This commit is contained in:
thinkphp
2016-06-06 18:48:09 +08:00
parent 2cb0f1ed4a
commit aa2e844b73

View File

@@ -102,6 +102,8 @@ abstract class Connection
'resultset_type' => Db::RESULTSET_ARRAY,
// 自动写入时间戳字段
'auto_timestamp' => false,
// 是否需要进行SQL性能分析
'sql_explain' => false,
];
// PDO连接参数
@@ -743,7 +745,7 @@ abstract class Connection
$log = $this->queryStr . ' [ RunTime:' . $runtime . 's ]';
$result = [];
// SQL性能分析
if (0 === stripos(trim($this->queryStr), 'select')) {
if ($this->config['sql_explain'] && 0 === stripos(trim($this->queryStr), 'select')) {
$result = $this->getExplain($this->queryStr);
}
// SQL监听