phpmyadmin /
sql-parser
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace PhpMyAdmin\SqlParser\Statements; |
||
| 6 | |||
| 7 | use PhpMyAdmin\SqlParser\Components\Condition; |
||
| 8 | use PhpMyAdmin\SqlParser\Components\Expression; |
||
| 9 | use PhpMyAdmin\SqlParser\Components\JoinKeyword; |
||
| 10 | use PhpMyAdmin\SqlParser\Components\Limit; |
||
| 11 | use PhpMyAdmin\SqlParser\Components\OrderKeyword; |
||
| 12 | use PhpMyAdmin\SqlParser\Components\SetOperation; |
||
| 13 | use PhpMyAdmin\SqlParser\Statement; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * `UPDATE` statement. |
||
| 17 | * |
||
| 18 | * UPDATE [LOW_PRIORITY] [IGNORE] table_reference |
||
| 19 | * [INNER JOIN | LEFT JOIN | JOIN] T1 ON T1.C1 = T2.C1 |
||
| 20 | * SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... |
||
| 21 | * [WHERE where_condition] |
||
| 22 | * [ORDER BY ...] |
||
| 23 | * [LIMIT row_count] |
||
| 24 | * |
||
| 25 | * or |
||
| 26 | * |
||
| 27 | * UPDATE [LOW_PRIORITY] [IGNORE] table_references |
||
| 28 | * SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... |
||
| 29 | * [WHERE where_condition] |
||
| 30 | */ |
||
| 31 | class UpdateStatement extends Statement |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * Options for `UPDATE` statements and their slot ID. |
||
| 35 | * |
||
| 36 | * @var array<string, int|array<int, int|string>> |
||
| 37 | * @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})> |
||
| 38 | */ |
||
| 39 | public static array $statementOptions = [ |
||
| 40 | 'LOW_PRIORITY' => 1, |
||
| 41 | 'IGNORE' => 2, |
||
| 42 | ]; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * The clauses of this statement, in order. |
||
| 46 | * |
||
| 47 | * @see Statement::$clauses |
||
| 48 | * |
||
| 49 | * @var array<string, array{non-empty-string, int-mask-of<self::ADD_*>}> |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 50 | */ |
||
| 51 | public static array $clauses = [ |
||
| 52 | 'UPDATE' => [ |
||
| 53 | 'UPDATE', |
||
| 54 | Statement::ADD_KEYWORD, |
||
| 55 | ], |
||
| 56 | // Used for options. |
||
| 57 | '_OPTIONS' => [ |
||
| 58 | '_OPTIONS', |
||
| 59 | Statement::ADD_CLAUSE, |
||
| 60 | ], |
||
| 61 | // Used for updated tables. |
||
| 62 | '_UPDATE' => [ |
||
| 63 | 'UPDATE', |
||
| 64 | Statement::ADD_CLAUSE, |
||
| 65 | ], |
||
| 66 | 'JOIN' => [ |
||
| 67 | 'JOIN', |
||
| 68 | Statement::ADD_CLAUSE, |
||
| 69 | ], |
||
| 70 | 'LEFT JOIN' => [ |
||
| 71 | 'LEFT JOIN', |
||
| 72 | Statement::ADD_CLAUSE, |
||
| 73 | ], |
||
| 74 | 'INNER JOIN' => [ |
||
| 75 | 'INNER JOIN', |
||
| 76 | Statement::ADD_CLAUSE, |
||
| 77 | ], |
||
| 78 | 'SET' => [ |
||
| 79 | 'SET', |
||
| 80 | Statement::ADD_CLAUSE | Statement::ADD_KEYWORD, |
||
| 81 | ], |
||
| 82 | 'WHERE' => [ |
||
| 83 | 'WHERE', |
||
| 84 | Statement::ADD_CLAUSE | Statement::ADD_KEYWORD, |
||
| 85 | ], |
||
| 86 | 'ORDER BY' => [ |
||
| 87 | 'ORDER BY', |
||
| 88 | Statement::ADD_CLAUSE | Statement::ADD_KEYWORD, |
||
| 89 | ], |
||
| 90 | 'LIMIT' => [ |
||
| 91 | 'LIMIT', |
||
| 92 | Statement::ADD_CLAUSE | Statement::ADD_KEYWORD, |
||
| 93 | ], |
||
| 94 | ]; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Tables used as sources for this statement. |
||
| 98 | * |
||
| 99 | * @var Expression[]|null |
||
| 100 | */ |
||
| 101 | public array|null $tables = null; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * The updated values. |
||
| 105 | * |
||
| 106 | * @var SetOperation[]|null |
||
| 107 | */ |
||
| 108 | public array|null $set = null; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Conditions used for filtering each row of the result set. |
||
| 112 | * |
||
| 113 | * @var Condition[]|null |
||
| 114 | */ |
||
| 115 | public array|null $where = null; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * Specifies the order of the rows in the result set. |
||
| 119 | * |
||
| 120 | * @var OrderKeyword[]|null |
||
| 121 | */ |
||
| 122 | public array|null $order = null; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Conditions used for limiting the size of the result set. |
||
| 126 | */ |
||
| 127 | public Limit|null $limit = null; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Joins. |
||
| 131 | * |
||
| 132 | * @var JoinKeyword[]|null |
||
| 133 | */ |
||
| 134 | public array|null $join = null; |
||
| 135 | } |
||
| 136 |