DebugDbProfiler
API reference › Yii3 Debug › Db › DebugDbProfiler
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.
Methods
Section titled “Methods”| Method | Description | Defined 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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
| Parameter | Type | Description |
|---|---|---|
$collector | Yii3\ | Collector receiving the captured statements and failures. |
$profiler | Yiisoft\ | Application profiler to keep feeding, or null when the debugger is the only observer. |
begin()
Section titled “begin() ”public function begin(string $token, array<array-key, mixed>|Yiisoft\Db\Profiler\ContextInterface $context = []): voidOpens a profiling block for one statement.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string | Statement text identifying the block. |
$context | array<array-key, | Profiling context supplied by the connection. |
end()
Section titled “end() ”public function end(string $token, array<array-key, mixed>|Yiisoft\Db\Profiler\ContextInterface $context = []): voidCloses the profiling block opened for the same token and records the statement.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string | Statement text identifying the block. |
$context | array<array-key, | Profiling context supplied by the connection. |
instrument()
Section titled “instrument() ”public function instrument(Yiisoft\Db\Driver\Pdo\PdoConnectionInterface&Yiisoft\Db\Profiler\ProfilerAwareInterface $connection): voidRegisters 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
| Parameter | Type | Description |
|---|---|---|
$connection | Yiisoft\ | Development connection to observe. |