DbCollector
API reference › Yii3 Debug › Collector › DbCollector
Retains completed database observations only within the current debugger request lifecycle.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
begin() | Opens a block for one statement. | DbCollector |
capture() | Encodes the captured statements into the Database panel payload. | DbCollector |
end() | Closes the block opened for the same token and records the completed statement. | DbCollector |
id() | Returns the stable identifier of this collector. | DbCollector |
isStarted() | Returns whether the collector is capturing for the current request. | DbCollector |
observe() | Records a statement already assembled elsewhere. | DbCollector |
reportFailure() | Records an instrumentation failure, so a broken profiler surfaces in the panel instead of silently dropping data. | DbCollector |
reportRows() | Records the row count reported by the statement that is about to complete. | DbCollector |
shutdown() | Stops capturing and clears the statements accumulated for the request. | DbCollector |
startup() | Starts capturing, discarding anything left from a previous request. | DbCollector |
Method details
Section titled “Method details”begin()
Section titled “begin() ”public function begin(string $token, float $time, list<array<string, mixed>> $trace): voidOpens a block for one statement.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string | Statement text identifying the block. |
$time | float | Start timestamp, in seconds. |
$trace | list<array<string, | Backtrace frames of the call site. |
capture()
Section titled “capture() ”public function capture(): array<string, mixed>|nullEncodes the captured statements into the Database panel payload.
Returns
array<string, mixed>|null: Encoded Db panel payload; null when the collector never started.
end()
Section titled “end() ”public function end(string $token, float $time): voidCloses the block opened for the same token and records the completed statement.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string | Statement text identifying the block. |
$time | float | Completion timestamp, in seconds. |
public function id(): stringReturns the stable identifier of this collector.
Returns
string: Stable ID pairing this collector with its panel.
isStarted()
Section titled “isStarted() ”public function isStarted(): boolReturns whether the collector is capturing for the current request.
Returns
bool: true while the collector is capturing; false otherwise.
observe()
Section titled “observe() ”public function observe(PHPForge\Debug\Panel\Db\QueryRow $row): voidRecords a statement already assembled elsewhere.
Parameters
| Parameter | Type | Description |
|---|---|---|
$row | PHPForge\ | Statement to append to the capture. |
reportFailure()
Section titled “reportFailure() ”public function reportFailure(Throwable $failure): voidRecords an instrumentation failure, so a broken profiler surfaces in the panel instead of silently dropping data.
Parameters
| Parameter | Type | Description |
|---|---|---|
$failure | Throwable | Failure raised while instrumenting the connection. |
reportRows()
Section titled “reportRows() ”public function reportRows(int|null $rows): voidRecords the row count reported by the statement that is about to complete.
The last report before end() wins, so a retry handler re-executing the same statement overrides the count
of the failed attempt.
Parameters
| Parameter | Type | Description |
|---|---|---|
$rows | int| | Rows returned or affected, or null when the statement did not complete. |
shutdown()
Section titled “shutdown() ”public function shutdown(): voidStops capturing and clears the statements accumulated for the request.
startup()
Section titled “startup() ”public function startup(): voidStarts capturing, discarding anything left from a previous request.