DebugStatement
API reference › Yii3 Debug › Db › DebugStatement
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.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() protected | Creates 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”protected function __construct(Yii3\Debug\Collector\DbCollector $collector)Creates a statement observer that reports row counts to the Database collector.
Parameters
| Parameter | Type | Description |
|---|---|---|
$collector | Yii3\ | Collector receiving the row count of every execution. |
execute()
Section titled “execute() ”public function execute(array<array-key, mixed>|null $params = null): boolExecutes 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
| Parameter | Type | Description |
|---|---|---|
$params | array<array-key, | Values bound to the statement placeholders, if any. |
Returns
bool: true when the driver accepted the statement; false otherwise.