Skip to content
PHP Ecosystem
Explore

QueryRow

API reference › Debug Core › Panel › Db › QueryRow

final classPHPForge\Debug\Panel\Db\QueryRow
ImplementsPHPForge\Debug\Storage\PanelRow
Sourcesrc/Panel/Db/QueryRow.php

Typed view-model for a single database query row consumed by the queries grid.

MethodDescriptionDefined by
create() staticCreates a captured statement with milliseconds as the common time unit.QueryRow
extractType() staticReturns the uppercase leading command verb of a statement, or '' when it starts with no letter.QueryRow
findBySequence() staticReturns the row whose sequence matches the requested one exactly, or null when none does.QueryRow
fromArray() staticNarrows one persisted statement of the database payload into a typed row.QueryRow
fromTiming() staticBuilds a typed row from one resolved logger timing.QueryRow
getDuplicate()Returns the number of occurrences of this exact query.QueryRow
getDuration()Returns the execution time in milliseconds.QueryRow
getQuery()Returns the captured SQL statement.QueryRow
getRows()Returns the driver-reported row count, or null when unavailable.QueryRow
getSequence()Returns the zero-based capture sequence.QueryRow
getTimestamp()Returns the capture timestamp in milliseconds since the Unix epoch.QueryRow
getTrace()Returns the captured source frames.QueryRow
getTraceHash()Returns the captured or derived caller hash.QueryRow
getType()Returns the extracted or explicitly captured command verb.QueryRow
isExplainable()Returns whether the statement produces a useful EXPLAIN plan.QueryRow
jsonSerialize()Returns the persisted row contract.QueryRow
withDuplicate()Returns a copy with the given duplicate count.QueryRow
withRows()Returns a copy with the driver-reported row count, or null when the driver did not report one.QueryRow
withSequence()Returns a copy with the given sequence index.QueryRow
withTrace()Returns a copy with the given source frames and the caller hash derived from them.QueryRow
withTraceHash()Returns a copy with an explicitly captured caller hash without changing the source frames.QueryRow
withType()Returns a copy with an explicitly captured SQL command verb without changing the statement.QueryRow
public static function create(string $query, float $duration, float $timestamp): self

Creates a captured statement with milliseconds as the common time unit.

Parameters

ParameterTypeDescription
$querystringFull SQL statement.
$durationfloatExecution time in milliseconds.
$timestampfloatCapture timestamp in milliseconds since the Unix epoch.

Returns

self: Row carrying the extracted command verb, without trace, sequence, or row count.

public static function extractType(string $sql): string

Returns the uppercase leading command verb of a statement, or '' when it starts with no letter.

Parameters

ParameterTypeDescription
$sqlstringSQL statement to inspect.

Returns

string: Uppercase command verb, or ''.

public static function findBySequence(list<self> $rows, string $seq): self|null

Returns the row whose sequence matches the requested one exactly, or null when none does.

The sequence is compared as a string, so a padded request such as '02' never matches sequence 2.

Parameters

ParameterTypeDescription
$rowslist<self>Captured rows to search.
$seqstringRequested sequence number.

Returns

self|null: Matching row, or null when the sequence was not captured.

public static function fromArray(mixed $data, string $path): self

Narrows one persisted statement of the database payload into a typed row.

Parameters

ParameterTypeDescription
$datamixedPersisted statement, expected to be an object carrying the declared shape.
$pathstringJSON path of the statement, used to report a malformed payload.

Returns

self: Row carrying every persisted statement field.

public static function fromTiming(array{info: string, category: string, timestamp: float, trace: array<int, array<string, mixed>>, level: int, duration: float, memory: int, memoryDiff: int, traceHash: string} $timing, string $type, int $seq, int|null $rows): self

Builds a typed row from one resolved logger timing.

Parameters

ParameterTypeDescription
$timingarray{info: string, category: string, timestamp: float, trace: array<int, array<string, mixed>>, level: int, duration: float, memory: int, memoryDiff: int, traceHash: string}Resolved timing. The duplicate count starts at 1; DbSnapshot::capture() resolves the real occurrences across the request.
$typestringUppercase SQL command verb extracted from the statement.
$seqintZero-based sequence index.
$rowsint|nullRows reported by the driver, or null when it reported none.

Returns

self: Row with the timing scaled to milliseconds.

public function getDuplicate(): int

Returns the number of occurrences of this exact query.

Returns

int

public function getDuration(): float

Returns the execution time in milliseconds.

Returns

float

public function getQuery(): string

Returns the captured SQL statement.

Returns

string

public function getRows(): int|null

Returns the driver-reported row count, or null when unavailable.

Returns

int|null

public function getSequence(): int

Returns the zero-based capture sequence.

Returns

int

public function getTimestamp(): float

Returns the capture timestamp in milliseconds since the Unix epoch.

Returns

float

public function getTrace(): list<array<string, mixed>>

Returns the captured source frames.

Returns

list<array<string, mixed>>: Captured backtrace frames.

public function getTraceHash(): string

Returns the captured or derived caller hash.

Returns

string

public function getType(): string

Returns the extracted or explicitly captured command verb.

Returns

string

public function isExplainable(): bool

Returns whether the statement produces a useful EXPLAIN plan.

Only single table-touching DML verbs (SELECT, INSERT, UPDATE, DELETE, REPLACE, WITH) qualify; multi-statement text and other verbs either error or return noise under EXPLAIN.

Returns

bool: true when the statement can be explained; false otherwise.

public function jsonSerialize(): array<string, mixed>

Returns the persisted row contract.

Returns

array<string, mixed>: Row fields in their persisted order.

public function withDuplicate(int $duplicate): self

Returns a copy with the given duplicate count.

Parameters

ParameterTypeDescription
$duplicateintNumber of times the exact same statement was emitted in this request (>= 1).

Returns

self: Copy carrying the duplicate count.

public function withRows(int|null $rows): self

Returns a copy with the driver-reported row count, or null when the driver did not report one.

Parameters

ParameterTypeDescription
$rowsint|nullRows returned or affected, or null when the driver reported none.

Returns

self: Copy carrying the row count.

public function withSequence(int $sequence): self

Returns a copy with the given sequence index.

Parameters

ParameterTypeDescription
$sequenceintZero-based sequence index assigned by the panel.

Returns

self: Copy carrying the sequence index.

public function withTrace(list<array<string, mixed>> $trace): self

Returns a copy with the given source frames and the caller hash derived from them.

Parameters

ParameterTypeDescription
$tracelist<array<string, mixed>>Argument-free source frames.

Returns

self: Copy carrying the frames and their derived caller hash.

public function withTraceHash(string $traceHash): self

Returns a copy with an explicitly captured caller hash without changing the source frames.

Call after QueryRow::withTrace() to preserve a logger-provided hash instead of the derived hash. A subsequent withTrace() call derives the hash again.

Parameters

ParameterTypeDescription
$traceHashstringCaptured caller hash, or '' when no caller was captured.

Returns

self: Copy carrying the hash unchanged.

public function withType(string $type): self

Returns a copy with an explicitly captured SQL command verb without changing the statement.

Parameters

ParameterTypeDescription
$typestringCaptured command verb, preserved without normalization.

Returns

self: Copy carrying the verb unchanged.