classInsertInto
final class InsertInto
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.The head of INSERT and REPLACE: the verb, its modifiers, the table and the optional column list.
Mirrors the server's PT_insert with its is_replace flag: REPLACE deletes a row that duplicates a unique key before it inserts the new one. REPLACE takes no IGNORE and no HIGH_PRIORITY; the written table has no correlation name. The keyword INTO is optional and always written. Source: https://dev.mysql.com/doc/refman/8.4/en/insert.html, https://dev.mysql.com/doc/refman/8.4/en/replace.html.
$replace = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('REPLACE LOW_PRIORITY t VALUES (1)');
[$replace->statement->into->replace, $replace->statement->into->priority, $replace->toString()] // => [true, \SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertPriority::Low, 'REPLACE LOW_PRIORITY INTO t VALUES (1)']Properties§
public bool $replacepublic InsertPriority|null $prioritypublic bool $ignorepublic WriteTarget $tablepublic ColumnList|null $columns = nullMethods§
public function __construct(
public bool $replace,
public InsertPriority|null $priority,
public bool $ignore,
public WriteTarget $table,
public ColumnList|null $columns = null,
)Parameters
$replace | bool | Whether the verb is REPLACE |
$priority | InsertPriority|null | The scheduling modifier |
$ignore | bool | Whether IGNORE turns errors into warnings |
$table | WriteTarget | The table the rows are written to |
$columns | ColumnList|null | The columns written; null for every column of the table |
Throws
InvalidConstruction When REPLACE has IGNORE or HIGH_PRIORITY, or the table has a correlation nameCalls 2
- static-call Check::input() line 47
- class-const InsertPriority::High() line 47
public function render(Output $out): voidWrites the verb, the modifiers, INTO, the table and the column list.
Parameters
$out | Output |
Calls 1
- method-call Output::keyword() line 56
Test cases 4§
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 2
Relations§
Instantiated in 4
- new SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:99
- new SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::statement() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:102
- new SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:123
- new SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule::legacy() packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:127
Type declarations 6
- type SqlSemantics\Platform\MySql\Lowering\Dml\Insert\InsertRule packages/sql-semantics-mysql/src/Lowering/Dml/Insert/InsertRule.php:136
- type SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:125
- type SqlSemantics\Platform\MySql\Rules\Dml\InsertFacts packages/sql-semantics-mysql/src/Rules/Dml/InsertFacts.php:182
- type SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertQuery packages/sql-semantics-mysql/src/Statement/Dml/Insert/InsertQuery.php:44
- type SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertRows packages/sql-semantics-mysql/src/Statement/Dml/Insert/InsertRows.php:49
- type SqlSemantics\Platform\MySql\Statement\Dml\Insert\InsertSet packages/sql-semantics-mysql/src/Statement/Dml/Insert/InsertSet.php:49