# SqlHighlighter

> Recognizes SQL statements and highlights them as escape-safe HTML for the DB, Log, and Profiling panels.

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

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

Recognizes SQL statements and highlights them as escape-safe HTML for the DB, Log, and Profiling panels.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`highlight()`](#method-highlight) static | Returns the SQL statement as fully escaped HTML with `yii-debug-sql-*` token spans. | `SqlHighlighter` |
| [`isStatement()`](#method-isStatement) static | Returns whether the value reads as a raw SQL statement rather than as a log or profiling sentence. | `SqlHighlighter` |

## Method details

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

```php
public static function highlight(string $sql): string
```

Returns the SQL statement as fully escaped HTML with `yii-debug-sql-*` token spans.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$sql` | `string` | Raw SQL statement to highlight. |

**Returns**

`string`: Escaped HTML with `yii-debug-sql-*` token spans.

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

```php
public static function isStatement(string $value): bool
```

Returns whether the value reads as a raw SQL statement rather than as a log or profiling sentence.

Panels whose rows mix both call this to decide when [`highlight()`](/docs/extensions/debug-core/reference/panel/db/sqlhighlighter/index.md#method-highlight) applies, so statements logged under a
category the panel does not know still render with the token spans of the queries grid.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Message or block description to inspect. |

**Returns**

`bool`: `true` when the value opens a SQL statement; `false` otherwise.