DebugPdoStatement
API reference › Debug › db › DebugPdoStatement
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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$rowCounts static | list<int| | 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 |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() protected | Visibility 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”protected function __construct()Visibility is protected because PDO::ATTR_STATEMENT_CLASS requires it; callers must not instantiate the
class outside of the PDO factory.
execute()
Section titled “execute() ”public function execute(array<int|string, mixed>|null $params = null): boolExecutes 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
| Parameter | Type | Description |
|---|---|---|
$params | array<int| | Values bound to the statement placeholders, if any. |
Returns
bool: true on success, false on failure.
Throws
PDOException: When the driver rejects the statement inPDO::ERRMODE_EXCEPTIONmode.