classUpdate
final class Update
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.UPDATE of one table or of several tables, with SET assignments, WHERE, ORDER BY and LIMIT.
Mirrors the server's PT_update: the statement is a multiple-table UPDATE when its table references hold more than one table. The facts follow MYSQL-UPDATE-001. Source: https://dev.mysql.com/doc/refman/8.4/en/update.html.
$update = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('UPDATE LOW_PRIORITY t SET a = a + 1 WHERE b = 2 ORDER BY a LIMIT 10');
[count($update->statement->assignments), $update->statement->where !== null, $update->toString()] // => [1, true, 'UPDATE LOW_PRIORITY t SET a = a + 1 WHERE b = 2 ORDER BY a LIMIT 10']Properties§
public list<Relation> $tablespublic list<Assignment> $assignmentspublic list<OrderItem> $orderBypublic WithClause|null $withpublic bool $lowPrioritypublic bool $ignorepublic Scalar|null $where = nullpublic Limit|null $limit = nullMethods§
public function __construct(
public WithClause|null $with,
public bool $lowPriority,
public bool $ignore,
list<Relation> $tables,
list<Assignment> $assignments,
public Scalar|null $where = null,
list<OrderItem> $orderBy = [],
public Limit|null $limit = null,
)Parameters
$with | WithClause|null | The common tables (MySQL 8.0 and later) |
$lowPriority | bool | Whether LOW_PRIORITY is written |
$ignore | bool | Whether IGNORE turns errors into warnings |
$tables | list<Relation> | The table references; at least one |
$assignments | list<Assignment> | The assignments; at least one |
$where | Scalar|null | The row predicate |
$orderBy | list<OrderItem> | The order the rows are updated in |
$limit | Limit|null | The most rows updated |
Throws
InvalidConstruction When there is no table or no assignmentCalls 4
- static-call Check::listOf() line 73
- class-const Relation::class() line 73
- class-const Assignment::class() line 74
- class-const OrderItem::class() line 75
public function deriveStatement(Derivation $derivation): voidDerives the tables, the assignments and the clauses; the statement returns no rows.
Parameters
$derivation | Derivation |
Calls 3
- method-call ChangeFacts::update() line 83
- new ChangeFacts line 83
- method-call Derivation::environment() line 83
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 3
- method-call Output::node() line 91
- method-call Output::keyword() line 93
- method-call Output::list() line 98
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.