final class InsertInto
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

The head of an INSERT statement: the verb, the conflict resolution, the written table and the column list.

REPLACE is the short spelling of INSERT OR REPLACE; the model keeps which one is written. Source: https://sqlite.org/lang_insert.html, https://sqlite.org/lang_replace.html.

Reading the head of an INSERTdoctest
$insert = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('INSERT OR IGNORE INTO t (a, b) VALUES (1, 2)');
    [$insert->statement->into->resolution, $insert->statement->into->target->name->name->value, count($insert->statement->into->columns)] // => [\SqlSemantics\Platform\Sqlite\Statement\Mutation\ConflictResolution::Ignore, 't', 2]
Refusing a conflict resolution next to REPLACEdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Mutation\InsertInto(new \SqlSemantics\Platform\Sqlite\Statement\Mutation\MutationTarget(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\QualifiedName(new \SqlSemantics\Platform\Sqlite\Model\Statement\Identifier\Name('t'))), [], true, \SqlSemantics\Platform\Sqlite\Statement\Mutation\ConflictResolution::Ignore) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public list<Name> $columns
public MutationTarget $target
public bool $replace = false
public ConflictResolution|null $resolution = null
public WithClause|null $with = null

Methods§

public function __construct(
    public MutationTarget $target,
    list<Name> $columns = [],
    public bool $replace = false,
    public ConflictResolution|null $resolution = null,
    public WithClause|null $with = null,
)

Parameters

$targetMutationTargetThe written table
$columnslist<Name>The columns that receive values; none when the list is absent
$replaceboolWhether the verb is REPLACE
$resolutionConflictResolution|nullThe algorithm written after INSERT OR
$withWithClause|nullThe WITH clause of the statement
Calls 3
public function render(Output $out): void

Writes the head up to the column list.

Parameters

$outOutput
Calls 5

Test cases 8§

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

Dedicated tests 2
Other tests reaching this symbol 6

Relations§

Instantiated in 2
Type declarations 6