-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace WebmanTech\Debugbar\DataCollector\PDO; | ||
|
||
use DebugBar\DataCollector\PDO\TraceablePDO as DebugbarTraceablePDO; | ||
use DebugBar\DataCollector\TimeDataCollector; | ||
|
||
class PDOCollector extends \DebugBar\DataCollector\PDO\PDOCollector | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
protected function collectPDO(DebugbarTraceablePDO $pdo, TimeDataCollector $timeCollector = null, $connectionName = null) | ||
{ | ||
$data = parent::collectPDO($pdo, $timeCollector, $connectionName); | ||
|
||
if ($pdo instanceof TraceablePDO) { | ||
// 清除历史记录,否则在 webman 常驻内存的情况下会有历史累计 | ||
$pdo->cleanExecutedStatements(); | ||
} | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace WebmanTech\Debugbar\DataCollector\PDO; | ||
|
||
class TraceablePDO extends \DebugBar\DataCollector\PDO\TraceablePDO | ||
{ | ||
/** | ||
* 清空历史 | ||
* @return void | ||
*/ | ||
public function cleanExecutedStatements() | ||
{ | ||
$this->executedStatements = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters