Skip to content
PHP Ecosystem
Explore

DebugPdoStatement

API reference › Debug › db › DebugPdoStatement

classyii\debug\db\DebugPdoStatement
ExtendsPDOStatement
Sourcesrc/db/DebugPdoStatement.php

Records the row count produced by every executed prepared statement.

The Yii profiler captures each query’s SQL and timing but discards the PDOStatement, so the row count is unrecoverable downstream. This subclass hooks PDOStatement::execute() to read rowCount() right after execution and append it to a request-scoped list in execution order.

Registered by DbCollector via PDO::ATTR_STATEMENT_CLASS on the collector-bound DB connection, so every prepared statement returned by the underlying PDO instance is one of these.

PropertyTypeDescriptionDefined by
$rowCounts staticlist<int|null>Row count per executed statement, appended in execution order; null marks a statement whose execution threw, so later statements keep their sequence position. Default: [].DebugPdoStatement
MethodDescriptionDefined by
__construct() protectedVisibility is protected because PDO::ATTR_STATEMENT_CLASS requires it; callers must not instantiate the class outside of the PDO factory.DebugPdoStatement
execute()Executes the prepared statement and records its row count in DebugPdoStatement::$rowCounts.DebugPdoStatement
protected function __construct()

Visibility is protected because PDO::ATTR_STATEMENT_CLASS requires it; callers must not instantiate the class outside of the PDO factory.

public function execute(array<int|string, mixed>|null $params = null): bool

Executes the prepared statement and records its row count in DebugPdoStatement::$rowCounts.

A statement that throws still occupies a slot, holding null, because the Database panel aligns the list with the trailing captured timings: skipping the failed statement would shift every later row count onto the wrong query.

Parameters

ParameterTypeDescription
$paramsarray<int|string, mixed>|nullValues bound to the statement placeholders, if any.

Returns

bool: true on success, false on failure.

Throws

  • PDOException: When the driver rejects the statement in PDO::ERRMODE_EXCEPTION mode.