Skip to content
PHP Ecosystem
Explore

DebugDbProfiler

API reference › Yii3 Debug › Db › DebugDbProfiler

final classYii3\Debug\Db\DebugDbProfiler
ImplementsYiisoft\Db\Profiler\ProfilerInterface
Sourcesrc/Db/DebugDbProfiler.php

Adapts Yii DB 2 command profiling to request-scoped Database observations without recording parameters or arguments.

Connection and command timings are also forwarded to the application profiler when configured. Only the native method category is forwarded; parameter arrays and exception objects are not copied.

MethodDescriptionDefined by
__construct()Creates a DB profiler that records statements while optionally forwarding spans.DebugDbProfiler
begin()Opens a profiling block for one statement.DebugDbProfiler
end()Closes the profiling block opened for the same token and records the statement.DebugDbProfiler
instrument()Registers this profiler on the connection and enables driver-reported row counts.DebugDbProfiler
public function __construct(Yii3\Debug\Collector\DbCollector $collector, Yiisoft\Profiler\ProfilerInterface|null $profiler = null)

Creates a DB profiler that records statements while optionally forwarding spans.

Parameters

ParameterTypeDescription
$collectorYii3\Debug\Collector\DbCollectorCollector receiving the captured statements and failures.
$profilerYiisoft\Profiler\ProfilerInterface|nullApplication profiler to keep feeding, or null when the debugger is the only observer.
public function begin(string $token, array<array-key, mixed>|Yiisoft\Db\Profiler\ContextInterface $context = []): void

Opens a profiling block for one statement.

Parameters

ParameterTypeDescription
$tokenstringStatement text identifying the block.
$contextarray<array-key, mixed>|Yiisoft\Db\Profiler\ContextInterfaceProfiling context supplied by the connection.
public function end(string $token, array<array-key, mixed>|Yiisoft\Db\Profiler\ContextInterface $context = []): void

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

Parameters

ParameterTypeDescription
$tokenstringStatement text identifying the block.
$contextarray<array-key, mixed>|Yiisoft\Db\Profiler\ContextInterfaceProfiling context supplied by the connection.
public function instrument(Yiisoft\Db\Driver\Pdo\PdoConnectionInterface&Yiisoft\Db\Profiler\ProfilerAwareInterface $connection): void

Registers this profiler on the connection and enables driver-reported row counts.

Statements are instrumented through PDO::ATTR_STATEMENT_CLASS, installed on the live PDO instance immediately when the connection is already open and again on every open, including the opens that precede the captured request. A connection wired with setProfiler() alone is still captured, but its Rows column stays empty.

Parameters

ParameterTypeDescription
$connectionYiisoft\Db\Driver\Pdo\PdoConnectionInterface&Yiisoft\Db\Profiler\ProfilerAwareInterfaceDevelopment connection to observe.