Skip to content

Internals Database Query SqlExpression

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

database\query\SqlExpression

Framework Internals · Subsystem overview · Developer guide

Source: awt_src/classes/database/query/SqlExpression.php · Snapshot 8411f4287706.

DatabaseManager delegates SQL generation to QueryBuilder, execution to IProvider, and result caching to ICache. Schema builders use MySQL DDL and the framework table registry.

SqlExpression

Declaration and architectural role

final readonly class SqlExpression

Source description (behavioral corrections are recorded in Known discrepancies):

Explicit supported SQL defaults; ordinary values remain bound parameters.

Constants, enum cases, traits and properties

Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.

Member Declaration Purpose or source contract
$sql public string $sql; Used by __construct().
Constructor-promoted public function __construct(string $sql) Initialized from the constructor argument; default expression is evaluated when the argument is omitted.

Method index

Method Signature
__construct public function __construct(string $sql)

__construct

Source line 8

public function __construct(string $sql)

Parameters

Parameter Type, modifiers and default Purpose
$sql string $sql Operation input; the exact use, validation and propagation are shown in the implementation trace.

State writes: $this->sql.

Explicit exceptions: \InvalidArgumentException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.

Implementation, validation guards and interaction order
public function __construct(string $sql)
    {
        $sql = strtoupper($sql);
        if (!in_array($sql, ['DEFAULT', 'CURRENT_TIMESTAMP'], true)) {
            throw new \InvalidArgumentException('Unsupported SQL expression.');
        }
        $this->sql = $sql;
    }

Clone this wiki locally