Skip to content
PHP Ecosystem
Explore

DbCollector

API reference › Yii3 Debug › Collector › DbCollector

final classYii3\Debug\Collector\DbCollector
ImplementsCollectorInterface
Sourcesrc/Collector/DbCollector.php

Retains completed database observations only within the current debugger request lifecycle.

MethodDescriptionDefined 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
public function begin(string $token, float $time, list<array<string, mixed>> $trace): void

Opens a block for one statement.

Parameters

ParameterTypeDescription
$tokenstringStatement text identifying the block.
$timefloatStart timestamp, in seconds.
$tracelist<array<string, mixed>>Backtrace frames of the call site.
public function capture(): array<string, mixed>|null

Encodes the captured statements into the Database panel payload.

Returns

array<string, mixed>|null: Encoded Db panel payload; null when the collector never started.

public function end(string $token, float $time): void

Closes the block opened for the same token and records the completed statement.

Parameters

ParameterTypeDescription
$tokenstringStatement text identifying the block.
$timefloatCompletion timestamp, in seconds.
public function id(): string

Returns the stable identifier of this collector.

Returns

string: Stable ID pairing this collector with its panel.

public function isStarted(): bool

Returns whether the collector is capturing for the current request.

Returns

bool: true while the collector is capturing; false otherwise.

public function observe(PHPForge\Debug\Panel\Db\QueryRow $row): void

Records a statement already assembled elsewhere.

Parameters

ParameterTypeDescription
$rowPHPForge\Debug\Panel\Db\QueryRowStatement to append to the capture.
public function reportFailure(Throwable $failure): void

Records an instrumentation failure, so a broken profiler surfaces in the panel instead of silently dropping data.

Parameters

ParameterTypeDescription
$failureThrowableFailure raised while instrumenting the connection.
public function reportRows(int|null $rows): void

Records 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

ParameterTypeDescription
$rowsint|nullRows returned or affected, or null when the statement did not complete.
public function shutdown(): void

Stops capturing and clears the statements accumulated for the request.

public function startup(): void

Starts capturing, discarding anything left from a previous request.