1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 13:28:35 +01:00

added option to render sql with params in PdoCollector (fixed #38)

This commit is contained in:
maximebf 2013-10-24 17:29:49 -04:00
parent 3e2a0245e9
commit f5cb5a1fcf

View File

@ -15,6 +15,8 @@ class PDOCollector extends DataCollector implements Renderable
protected $timeCollector; protected $timeCollector;
protected $renderSqlWithParams = false;
/** /**
* @param TraceablePDO $pdo * @param TraceablePDO $pdo
* @param TimeDataCollector $timeCollector * @param TimeDataCollector $timeCollector
@ -27,6 +29,21 @@ class PDOCollector extends DataCollector implements Renderable
} }
} }
/**
* Renders the SQL of traced statements with params embeded
*
* @param boolean $enabled
*/
public function setRenderSqlWithParams($enabled = true)
{
$this->renderSqlWithParams = $enabled;
}
public function isSqlRenderedWithParams()
{
return $this->renderSqlWithParams;
}
/** /**
* Adds a new PDO instance to be collector * Adds a new PDO instance to be collector
* *
@ -92,7 +109,7 @@ class PDOCollector extends DataCollector implements Renderable
$stmts = array(); $stmts = array();
foreach ($pdo->getExecutedStatements() as $stmt) { foreach ($pdo->getExecutedStatements() as $stmt) {
$stmts[] = array( $stmts[] = array(
'sql' => $stmt->getSql(), 'sql' => $this->renderSqlWithParams ? $stmt->getSqlWithParams() : $stmt->getSql(),
'row_count' => $stmt->getRowCount(), 'row_count' => $stmt->getRowCount(),
'stmt_id' => $stmt->getPreparedId(), 'stmt_id' => $stmt->getPreparedId(),
'prepared_stmt' => $stmt->getSql(), 'prepared_stmt' => $stmt->getSql(),