# DbQueryRenderer

> Renders the typed cells of the queries grid for the DB debug panel.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Db](/docs/extensions/debug-core/reference/panel/db/index.md) › DbQueryRenderer

| final class | `PHPForge\Debug\Panel\Db\DbQueryRenderer` |
| --- | --- |
| Source | [`src/Panel/Db/DbQueryRenderer.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Db/DbQueryRenderer.php#L25) |

Renders the typed cells of the queries grid for the DB debug panel.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`renderDurationCell()`](#method-renderDurationCell) static | Renders the statement duration formatted as `N.N ms`. | `DbQueryRenderer` |
| [`renderNPlusOneSummary()`](#method-renderNPlusOneSummary) static | Renders an actionable summary linking each potential N+1 group to its first query. | `DbQueryRenderer` |
| [`renderQueryCell()`](#method-renderQueryCell) static | Renders the SQL statement column with its optional collapsed backtrace and EXPLAIN toggle. | `DbQueryRenderer` |
| [`renderRowsCell()`](#method-renderRowsCell) static | Renders the rows-affected cell, falling back to an en dash (`–`) when the driver did not report the count. | `DbQueryRenderer` |
| [`renderTimeCell()`](#method-renderTimeCell) static | Renders the capture time as `H:i:s.mmm`, derived from the row's millisecond timestamp. | `DbQueryRenderer` |
| [`renderTypeCell()`](#method-renderTypeCell) static | Renders the statement-type pill (`SELECT`, `INSERT`, `UPDATE`, ...), tinted by its vocabulary verb. | `DbQueryRenderer` |

## Method details

### renderDurationCell() <span id="method-renderDurationCell"></span>

```php
public static function renderDurationCell(PHPForge\Debug\Panel\Db\QueryRow $row): string
```

Renders the statement duration formatted as `N.N ms`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | [`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md) |  |

**Returns**

`string`

### renderNPlusOneSummary() <span id="method-renderNPlusOneSummary"></span>

```php
public static function renderNPlusOneSummary(list<PHPForge\Debug\Panel\Db\NPlusOneFinding> $findings, string $context = ''): string
```

Renders an actionable summary linking each potential N+1 group to its first query.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$findings` | `list<`[`NPlusOneFinding`](/docs/extensions/debug-core/reference/panel/db/nplusonefinding/index.md)`>` |  |
| `$context` | `string` | Optional plain-text scope appended to the visible heading and accessible label. |

**Returns**

`string`

### renderQueryCell() <span id="method-renderQueryCell"></span>

```php
public static function renderQueryCell(PHPForge\Debug\Panel\Db\QueryRow $row, Closure(array<string, mixed>): string $traceLine, bool $hasExplain, callable(int): string $explainUrlBuilder, PHPForge\Debug\Panel\Db\NPlusOneFinding|null $nPlusOneFinding = null): string
```

Renders the SQL statement column with its optional collapsed backtrace and EXPLAIN toggle.

The caller supplies a URL builder so the renderer stays free of routing concerns and easy to test in isolation
(typically `static fn(int $seq) => Url::to(['db-explain', 'seq' => $seq, ...])`).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | [`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md) | Typed query record. |
| `$traceLine` | [`Closure`](https://www.php.net/manual/en/class.closure.php)`(array<string, mixed>): string` | Renders one backtrace frame as a link line. |
| `$hasExplain` | `bool` | `true` when the active driver supports EXPLAIN; the row must also be EXPLAIN-eligible. |
| `$explainUrlBuilder` | `callable(int): string` | Builds the EXPLAIN URL for the given query sequence index. |
| `$nPlusOneFinding` | [`NPlusOneFinding`](/docs/extensions/debug-core/reference/panel/db/nplusonefinding/index.md)`\|null` |  |

**Returns**

`string`

### renderRowsCell() <span id="method-renderRowsCell"></span>

```php
public static function renderRowsCell(PHPForge\Debug\Panel\Db\QueryRow $row): string
```

Renders the rows-affected cell, falling back to an en dash (`–`) when the driver did not report the count.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | [`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md) |  |

**Returns**

`string`

### renderTimeCell() <span id="method-renderTimeCell"></span>

```php
public static function renderTimeCell(PHPForge\Debug\Panel\Db\QueryRow $row): string
```

Renders the capture time as `H:i:s.mmm`, derived from the row's millisecond timestamp.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | [`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md) |  |

**Returns**

`string`

### renderTypeCell() <span id="method-renderTypeCell"></span>

```php
public static function renderTypeCell(PHPForge\Debug\Panel\Db\QueryRow $row): string
```

Renders the statement-type pill (`SELECT`, `INSERT`, `UPDATE`, ...), tinted by its vocabulary verb.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | [`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md) |  |

**Returns**

`string`