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.

Reading an UPDATEdoctest
$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> $tables
public list<Assignment> $assignments
public list<OrderItem> $orderBy
public WithClause|null $with
public bool $lowPriority
public bool $ignore
public Scalar|null $where = null
public Limit|null $limit = null

Methods§

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

$withWithClause|nullThe common tables (MySQL 8.0 and later)
$lowPriorityboolWhether LOW_PRIORITY is written
$ignoreboolWhether IGNORE turns errors into warnings
$tableslist<Relation>The table references; at least one
$assignmentslist<Assignment>The assignments; at least one
$whereScalar|nullThe row predicate
$orderBylist<OrderItem>The order the rows are updated in
$limitLimit|nullThe most rows updated

Throws

InvalidConstruction When there is no table or no assignment
Calls 4
public function deriveStatement(Derivation $derivation): void

Derives the tables, the assignments and the clauses; the statement returns no rows.

Parameters

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

Writes the statement.

Parameters

$outOutput
Calls 3

Test cases 6§

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 4

Relations§

Instantiated in 1
Type declarations 2