Skip to content
PHP Ecosystem
Explore

DebugStatement

API reference › Yii3 Debug › Db › DebugStatement

final classYii3\Debug\Db\DebugStatement
ExtendsPDOStatement
Sourcesrc/Db/DebugStatement.php

Reports the driver row count of every executed prepared statement to the request-scoped Database collector.

Yii DB 2 profiling hands observers the SQL and its context only, so the PDOStatement and its rowCount() are unreachable downstream. DebugDbProfiler::instrument() registers this class through PDO::ATTR_STATEMENT_CLASS on the live PDO instance, making every prepared statement report its own count.

MethodDescriptionDefined by
__construct() protectedCreates a statement observer that reports row counts to the Database collector.DebugStatement
execute()Executes the prepared statement and reports its row count, or null when the driver rejects it.DebugStatement
protected function __construct(Yii3\Debug\Collector\DbCollector $collector)

Creates a statement observer that reports row counts to the Database collector.

Parameters

ParameterTypeDescription
$collectorYii3\Debug\Collector\DbCollectorCollector receiving the row count of every execution.
public function execute(array<array-key, mixed>|null $params = null): bool

Executes the prepared statement and reports its row count, or null when the driver rejects it.

A rejected statement still reports, holding null, so a command that never produced a count is not credited with the count of an earlier attempt.

Parameters

ParameterTypeDescription
$paramsarray<array-key, mixed>|nullValues bound to the statement placeholders, if any.

Returns

bool: true when the driver accepted the statement; false otherwise.