final class Prepare
    implements Statement
    uses Snapshot
Public API: explicitly declared with @visibility public.

PREPARE: a statement stored under a name in the session, with the types of its parameters.

Mirrors PostgreSQL's PrepareStmt (name, argtypes, query). Rule: PG-PREPARE-001. The statement is derived as a nested query in an environment that sees only the declared parameter types (PG-PREPARE-PARAMETERS-001), so $n has the declared type of its position; preparing it returns no rows and declares no relation. A selection with INTO is admitted as the first selection of a query statement only (PG-PLACEMENT-001). Source: https://www.postgresql.org/docs/17/sql-prepare.html. Status: Implemented.

Reading a prepared statementdoctest
$prepare = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('PREPARE p (integer) AS SELECT $1');
    [$prepare->statement->name->value, count($prepare->statement->parameters->types), $prepare->toString()] // => ['p', 1, 'PREPARE p (INTEGER) AS SELECT $1']

Properties§

public Name $name
public PreparedParameters|null $parameters
public Query $statement

Methods§

public function __construct(
    public Name $name,
    public PreparedParameters|null $parameters,
    public Query $statement,
)

Parameters

$nameNameThe name of the prepared statement
$parametersPreparedParameters|nullThe declared parameter types; null when none is written
$statementQueryThe statement prepared: a query statement or a data-modifying statement

Throws

InvalidConstruction When the statement is of another kind
Calls 3
public function deriveStatement(Derivation $derivation): void
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 3

Test cases 8§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 7

Relations§

Instantiated in 1
Type declarations 1