# DbSnapshot

> Canonical database panel snapshot holding the resolved query rows in their typed form.

[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) › DbSnapshot

| final readonly class | `PHPForge\Debug\Panel\Db\DbSnapshot` |
| --- | --- |
| Implements | [`PHPForge\Debug\Storage\PanelSnapshot`](/docs/extensions/debug-core/reference/storage/panelsnapshot/index.md) |
| Source | [`src/Panel/Db/DbSnapshot.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Db/DbSnapshot.php#L15) |

Canonical database panel snapshot holding the resolved query rows in their typed form.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a database snapshot from captured query rows. | `DbSnapshot` |
| [`capture()`](#method-capture) static | Resolves exact SQL duplicates while preserving capture order and the persisted row contract. | `DbSnapshot` |
| [`entries()`](#method-entries) | Returns the captured query rows. | `DbSnapshot` |
| [`fromArray()`](#method-fromArray) static | Narrows the persisted database payload into a typed snapshot. | `DbSnapshot` |
| [`jsonSerialize()`](#method-jsonSerialize) | Returns the panel snapshot for JSON serialization. | `DbSnapshot` |

## Method details

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

```php
public function __construct(list<PHPForge\Debug\Panel\Db\QueryRow> $entries)
```

Creates a database snapshot from captured query rows.

**Parameters**

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

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

```php
public static function capture(list<PHPForge\Debug\Panel\Db\QueryRow> $rows): self
```

Resolves exact SQL duplicates while preserving capture order and the persisted row contract.

**Parameters**

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

**Returns**

`self`

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

```php
public function entries(): list<PHPForge\Debug\Panel\Db\QueryRow>
```

Returns the captured query rows.

**Returns**

`list<`[`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md)`>`: Executed statements in capture order.

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

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

Narrows the persisted database payload into a typed snapshot.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$data` | `mixed` | Persisted payload, expected to be an object carrying an `entries` list. |
| `$path` | `string` | JSON path of the payload, used to report a malformed capture. |

**Returns**

`self`: Snapshot carrying the persisted query rows.

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

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

Returns the panel snapshot for JSON serialization.

**Returns**

`array<string, mixed>`