php - how to log only successfully executed query in yii2 similar like profile log
问题描述
I have successfully implemented profile log in yii2 that will log all executed mysql query. But the problem is, it also log the query that are rollback during the process. I want to keep record of all successfully executed query and keep it as backup/mirror. Is there any way i can achieve this. I tried using Dbtarget log and commented the following part
public function export() {
if ($this->db->getTransaction()) {
// create new database connection, if there is an open transaction
// to ensure insert statement is not affected by a rollback
this is my comment=>// $this->db = clone $this->db;
}
But still it did not worked.
解决方案
This can be achieve by checking category of query in yii2. Each query are categorized in yii2 as query,execution and each execution query starts transaction start and end with rollback or commit. So only save the execution query having that ends with commit category in Dbtarget class.
推荐阅读
- c# - 使用自定义 dll 时 SISS 包损坏
- javascript - 逗号分隔、冒号或破折号分隔值的 MAC 地址正则表达式验证
- google-chrome - Joomla 页面有多少级缓存
- r - 重新采样/聚合 NetCDF 文件以解析第二个 NetCDF 文件
- android-studio - 此版本的 Android Studio 无法打开此项目,请使用 Android Studio 3.5 或更高版本重试
- python - 用不同列表中的元素(单词)替换列表中的元素(单词)
- unit-testing - Spring MVC 4.2:如何使用 @RequestPart 参数对控制器进行单元测试
- javascript - 当用户滚动时在 ReactJS 组件上添加/删除一个类
- spring-boot - 使用 WebClient 将带有标头的请求发送到第三方 api
- android - 如何制作自定义 ListView?