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

INSERT or REPLACE of the rows of a query (SELECT, TABLE, VALUES or a set operation), with the optional ON DUPLICATE KEY UPDATE.

Rule: MYSQL-INSERT-QUERY-001. The facts follow MYSQL-INSERT-001 with the query as the source. Source: https://dev.mysql.com/doc/refman/8.4/en/insert-select.html. Status: Implemented.

Reading the source of an INSERT ... SELECTdoctest
$insert = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('INSERT INTO t (a) SELECT b FROM u');
    [$insert->statement->source instanceof \SqlSemantics\Platform\MySql\Statement\Query\Select, $insert->toString()] // => [true, 'INSERT INTO t (a) SELECT b FROM u']

Properties§

public list<Assignment> $onDuplicate
public InsertInto $into
public Query $source

Methods§

public function __construct(
    public InsertInto $into,
    public Query $source,
    list<Assignment> $onDuplicate = [],
)

Parameters

$intoInsertIntoThe head: verb, modifiers, table and column list
$sourceQueryThe query whose rows are written
$onDuplicatelist<Assignment>The assignments of ON DUPLICATE KEY UPDATE

Throws

InvalidConstruction When REPLACE has ON DUPLICATE KEY UPDATE
Calls 3
public function deriveStatement(Derivation $derivation): void

Derives the written table, the columns, the query and the assignments; the statement returns no rows.

Parameters

$derivationDerivation
Calls 3
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 2

Test cases 2§

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 1

Relations§

Instantiated in 1
Type declarations 1