Skip to content
PHP Ecosystem
Explore

DbPanel

API reference › Debug › panels › DbPanel

Renders the database queries captured by the Database collector.

Presents the queries grid with per-query timings, the duplicate-query summary, and the EXPLAIN action that powers the grid’s inline plan toggle; data acquisition lives in DbCollector.

PropertyTypeDescriptionDefined by
$actionsarray<string, array<string, mixed>|class-string>Standalone actions merged into the debug module’s Module::$actionMap, keyed by action ID. Default: [].yii\debug\Panel
$behaviors read-onlyarray<yii\base\Behavior<static>>List of behaviors attached to this component.yii\base\Component
$criticalQueryThresholdint|nullCritical-query-count threshold; when the captured query count exceeds this value the toolbar item flips to a warning state. null disables the check. Default: null.DbPanel
$dbstringApplication component id of the DB connection used to run EXPLAIN queries. Default: 'db'.DbPanel
$defaultFilterarray<string, mixed>Default filter applied to the queries grid as property => value (for example, ['type' => 'SELECT']). Default: [].DbPanel
$defaultOrderarray<string, int>Default sort order applied to the queries grid as property => SORT_* (for example, ['duration' => SORT_DESC]). Default: ['seq' => SORT_ASC].DbPanel
$detail read-onlystringRendered detail view.DbPanel
$idstringPanel unique identifier, assigned by the container module on registration. Default: ''.yii\debug\Panel
$moduleyii\debug\Module|nullDebug module owning this panel. Default: null.yii\debug\Panel
$name read-onlystringPanel display name.DbPanel
$renderContextPHPForge\Debug\Panel\PanelRenderContext|nullPrepared render context, or null outside a debugger request.yii\debug\Panel
$rows read-onlylist<PHPForge\Debug\Panel\Db\QueryRow>Rows in capture order.DbPanel
$summary read-onlyPHPForge\Debug\Panel\Db\DbSummaryQuery metrics for the whole request.DbPanel
$tagstringTag of the request whose data this panel currently exposes. Default: ''.yii\debug\Panel
$toolbarData read-onlyarray<string, mixed>Toolbar envelope; [] to skip the panel.yii\debug\Panel
$toolbarIcon read-onlystringToolbar icon key.DbPanel
$types read-onlyarray<string, string>type => type map suitable for a dropdown filter.DbPanel
$url read-onlystringAbsolute URL to the panel detail view.yii\debug\Panel
$viewPath read-onlystringDirectory the panel views resolve against.yii\debug\Panel
$error protectedPHPForge\Debug\Storage\ExceptionSnapshot|nullException captured when the panel failed to produce or hydrate its snapshot. Default: null.yii\debug\Panel
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.yii\base\Component
__clone()This method is called after the object is created by cloning an existing one.yii\base\Component
__get()Returns the value of a component property.yii\base\Component
__isset()Checks if a property is set, i.e. defined and not null.yii\base\Component
__set()Sets the value of a component property.yii\base\Component
__unset()Sets a component property to be null.yii\base\Component
attachBehavior()Attaches a behavior to this component.yii\base\Component
attachBehaviors()Attaches a list of behaviors to the component.yii\base\Component
behaviors()Returns a list of behaviors that this component should behave as.yii\base\Component
canGetProperty()Returns a value indicating whether a property can be read.yii\base\Component
canSetProperty()Returns a value indicating whether a property can be set.yii\base\Component
capture()Captures the panel payload for the current request.yii\debug\Panel
className() staticReturns the fully qualified name of this class.yii\base\BaseObject
detachBehavior()Detaches a behavior from the component.yii\base\Component
detachBehaviors()Detaches all behaviors from the component.yii\base\Component
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.yii\base\Component
getBehavior()Returns the named behavior object.yii\base\Component
getBehaviors()Returns all behaviors attached to this component.yii\base\Component
getDb()Returns the DB connection used by the panel for EXPLAIN queries.DbPanel
getDetail()Renders the detail view with the queries grid, the EXPLAIN toggle, and the duplicate-query summary.DbPanel
getError()Returns the exception captured while collecting the panel payload, if any.yii\debug\Panel
getName()Returns the panel display name from the shared title enum.DbPanel
getRenderContext()Returns the framework-neutral render context for the active debugger request, when one has been prepared.yii\debug\Panel
getRows()Returns the executed statements as typed rows hydrated from the stored snapshot.DbPanel
getSummary()Returns the request-wide query metrics, computed once per hydrated snapshot and reused by every consumer.DbPanel
getToolbarData()Returns the toolbar envelope wrapping the panel’s icon, items, and URL.yii\debug\Panel
getToolbarIcon()Returns the icon key from the shared panel icon enum.DbPanel
getTraceLine()Builds a trace line for the toolbar through the shared Trace renderer, applying Module::$tracePathMappings and the configured Module::$traceLine template (or callable).yii\debug\Panel
getTypes()Returns the distinct SQL statement types captured for the request, keyed and valued by the same uppercase token.DbPanel
getUrl()Returns the URL pointing to this panel’s detail view for the current request tag.yii\debug\Panel
getViewPath()Returns the directory under which the panel’s relative views resolve.yii\debug\Panel
hasContent()Returns whether the panel captured content for the loaded request.yii\debug\Panel
hasError()Returns true when setError() captured an exception during panel capture or hydration.yii\debug\Panel
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.yii\base\Component
hasMethod()Returns a value indicating whether a method is defined.yii\base\Component
hasProperty()Returns a value indicating whether a property is defined for this component.yii\base\Component
hydrate()Decodes the captured payload into the typed query snapshot and discards the memoized summary.DbPanel
init()Registers the db-explain action.DbPanel
isEnabled()Returns whether the panel can run: requires both a resolvable DB connection and the parent enable check.DbPanel
isQueryCountCritical()Returns whether the given query count exceeds $criticalQueryThreshold.DbPanel
isVisible()Returns whether the panel should appear in the toolbar and sidebar navigation.yii\debug\Panel
moduleBound()Completes module-dependent wiring after the container module binds $id and $module.yii\debug\Panel
off()Detaches an existing event handler from this component.yii\base\Component
on()Attaches an event handler to an event.yii\base\Component
setError()Records an exception thrown during capture or hydration so LogTarget can surface it in the UI.yii\debug\Panel
setRenderContext()Installs the framework-neutral render context prepared for this panel by the debugger action.yii\debug\Panel
trigger()Triggers an event.yii\base\Component
getModels() protectedReturns the typed query rows consumed by the queries grid.DbPanel
getToolbarItems() protectedBuilds the query-count toolbar chip, with a warning when the count is critical or callers are excessive.DbPanel
getTotalQueryTime() protectedReturns the sum of every captured query’s duration.DbPanel
hasExplain() protectedReturns whether the DB connection’s driver supports the EXPLAIN action (currently mysql, sqlite, pgsql).DbPanel
public function getDb(): yii\db\Connection

Returns the DB connection used by the panel for EXPLAIN queries.

Returns

yii\db\Connection: Connection the EXPLAIN action runs against.

Throws

public function getDetail(): string

Renders the detail view with the queries grid, the EXPLAIN toggle, and the duplicate-query summary.

Returns

string: Rendered detail view.

Throws

public function getName(): string

Returns the panel display name from the shared title enum.

Returns

string: Panel display name.

public function getRows(): list<PHPForge\Debug\Panel\Db\QueryRow>

Returns the executed statements as typed rows hydrated from the stored snapshot.

Returns

list<PHPForge\Debug\Panel\Db\QueryRow>: Rows in capture order.

public function getSummary(): PHPForge\Debug\Panel\Db\DbSummary

Returns the request-wide query metrics, computed once per hydrated snapshot and reused by every consumer.

Returns

PHPForge\Debug\Panel\Db\DbSummary: Query metrics for the whole request.

public function getToolbarIcon(): string

Returns the icon key from the shared panel icon enum.

Returns

string: Toolbar icon key.

public function getTypes(): array<string, string>

Returns the distinct SQL statement types captured for the request, keyed and valued by the same uppercase token.

Returns

array<string, string>: type => type map suitable for a dropdown filter.

public function hydrate(array<string, mixed> $payload): void

Decodes the captured payload into the typed query snapshot and discards the memoized summary.

Parameters

ParameterTypeDescription
$payloadarray<string, mixed>Captured panel payload.

Throws

  • PHPForge\Debug\Storage\HydrationException: when the payload does not match the snapshot schema.
public function init(): void

Registers the db-explain action.

public function isEnabled(): bool

Returns whether the panel can run: requires both a resolvable DB connection and the parent enable check.

Returns

bool: true when a DB connection resolves and the parent check passes; false otherwise.

public function isQueryCountCritical(int $count): bool

Returns whether the given query count exceeds $criticalQueryThreshold.

Parameters

ParameterTypeDescription
$countintQuery count to test.

Returns

bool: true when the count exceeds the threshold; false otherwise.

protected function getModels(): list<PHPForge\Debug\Panel\Db\QueryRow>

Returns the typed query rows consumed by the queries grid.

Returns

list<PHPForge\Debug\Panel\Db\QueryRow>: Rows in capture order, suitable for ArrayDataProvider.

protected function getToolbarItems(): array<int, array<string, mixed>>

Builds the query-count toolbar chip, with a warning when the count is critical or callers are excessive.

Returns

array<int, array<string, mixed>>: Toolbar items, or [] when no queries were captured.

protected function getTotalQueryTime(): float

Returns the sum of every captured query’s duration.

Returns

float: Total query time, in milliseconds.

protected function hasExplain(): bool

Returns whether the DB connection’s driver supports the EXPLAIN action (currently mysql, sqlite, pgsql).

Returns

bool: true when the driver supports EXPLAIN; false otherwise.

Throws