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

INSERT or REPLACE of rows written in a VALUES clause, with the optional row alias and ON DUPLICATE KEY UPDATE.

Rule: MYSQL-INSERT-ROWS-001. The facts follow MYSQL-INSERT-001 with the rows of VALUES as the source; VALUE is a synonym of VALUES. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html. Status: Implemented.

Reading the rows of an INSERTdoctest
$insert = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("INSERT IGNORE INTO t (a, b) VALUE (1, 'x'), (2, DEFAULT) ON DUPLICATE KEY UPDATE b = VALUES(b)");
    [count($insert->statement->rows), count($insert->statement->onDuplicate), $insert->toString()] // => [2, 1, "INSERT IGNORE INTO t (a, b) VALUES (1, 'x'), (2, DEFAULT) ON DUPLICATE KEY UPDATE b = VALUES(b)"]

Properties§

public list<InsertedRow> $rows
public list<Assignment> $onDuplicate
public InsertInto $into
public RowAlias|null $alias = null

Methods§

public function __construct(
    public InsertInto $into,
    list<InsertedRow> $rows,
    public RowAlias|null $alias = null,
    list<Assignment> $onDuplicate = [],
)

Parameters

$intoInsertIntoThe head: verb, modifiers, table and column list
$rowslist<InsertedRow>The rows; at least one
$aliasRowAlias|nullThe alias of the new row
$onDuplicatelist<Assignment>The assignments of ON DUPLICATE KEY UPDATE

Throws

InvalidConstruction When there is no row, or REPLACE has an alias or ON DUPLICATE KEY UPDATE
Calls 4
public function deriveStatement(Derivation $derivation): void

Derives the written table, the columns, the rows 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 7§

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 6

Relations§

Instantiated in 1
Type declarations 1