# DbExplain

> Runs non-ANALYZE plans for captured single DML statements on an explicitly configured development connection.

[API reference](/docs/api/index.md) › [Yii3 Debug](/docs/extensions/yii3-debug/reference/index.md) › [Db](/docs/extensions/yii3-debug/reference/db/index.md) › DbExplain

| final readonly class | `Yii3\Debug\Db\DbExplain` |
| --- | --- |
| Source | [`src/Db/DbExplain.php`](https://github.com/yii3/debug/blob/main/src/Db/DbExplain.php#L14) |

Runs non-ANALYZE plans for captured single DML statements on an explicitly configured development connection.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates a query-plan runner for the configured development connection. | `DbExplain` |
| [`available()`](#method-available) | Returns whether query plans can be produced for the configured connection. | `DbExplain` |
| [`render()`](#method-render) | Runs the plan for one captured statement and renders it. | `DbExplain` |

## Method details

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

```php
public function __construct(Yiisoft\Db\Connection\ConnectionInterface|null $connection = null)
```

Creates a query-plan runner for the configured development connection.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$connection` | `Yiisoft\Db\Connection\ConnectionInterface\|null` | Development connection the plans run on, or `null` to disable the feature. |

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

```php
public function available(): bool
```

Returns whether query plans can be produced for the configured connection.

**Returns**

`bool`: `true` when a connection is configured and its driver supports plans; `false` otherwise.

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

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

Runs the plan for one captured statement and renders it.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$row` | `PHPForge\Debug\Panel\Db\QueryRow` | Captured statement to explain. |

**Returns**

`string`: Rendered plan, or a rendered error when the statement cannot be explained.