classInsertSet
final class InsertSet
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.INSERT or REPLACE of one row written as SET assignments, with the optional row alias and ON DUPLICATE KEY UPDATE.
Rule: MYSQL-INSERT-SET-001. The facts follow MYSQL-INSERT-001; the assigned columns are the written columns and must be distinct. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html. Status: Implemented.
$insert = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('INSERT INTO t SET a = 1, b = a + 1');
[count($insert->statement->assignments), $insert->toString()] // => [2, 'INSERT INTO t SET a = 1, b = a + 1']Properties§
public list<Assignment> $assignmentspublic list<Assignment> $onDuplicatepublic InsertInto $intopublic RowAlias|null $alias = nullMethods§
public function __construct(
public InsertInto $into,
list<Assignment> $assignments,
public RowAlias|null $alias = null,
list<Assignment> $onDuplicate = [],
)Parameters
$into | InsertInto | The head: verb, modifiers and table; no column list |
$assignments | list<Assignment> | The assignments of the row; at least one |
$alias | RowAlias|null | The alias of the new row |
$onDuplicate | list<Assignment> | The assignments of ON DUPLICATE KEY UPDATE |
Throws
InvalidConstruction When the head has a column list, there is no assignment, or REPLACE has an alias or ON DUPLICATE KEY UPDATECalls 3
- static-call Check::input() line 51
- static-call Check::listOf() line 52
- class-const Assignment::class() line 52
public function deriveStatement(Derivation $derivation): voidDerives the written table, the assignments and the assignments of ON DUPLICATE KEY UPDATE; the statement returns no rows.
Parameters
$derivation | Derivation |
Calls 3
- method-call InsertFacts::set() line 62
- new InsertFacts line 62
- method-call Derivation::environment() line 62
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 70
- method-call Output::keyword() line 72
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.