-
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathSetStatement.php
More file actions
105 lines (93 loc) · 2.27 KB
/
SetStatement.php
File metadata and controls
105 lines (93 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Statements;
use PhpMyAdmin\SqlParser\Components\OptionsArray;
use PhpMyAdmin\SqlParser\Components\SetOperation;
use PhpMyAdmin\SqlParser\Parsers\SetOperations;
use PhpMyAdmin\SqlParser\Statement;
use function trim;
/**
* `SET` statement.
*/
class SetStatement extends Statement
{
/**
* The clauses of this statement, in order.
*
* @see Statement::$clauses
*
* @var array<string, array{non-empty-string, int-mask-of<self::ADD_*>}>
*/
public static array $clauses = [
'SET' => [
'SET',
Statement::ADD_CLAUSE | Statement::ADD_KEYWORD,
],
'_END_OPTIONS' => [
'_END_OPTIONS',
Statement::ADD_CLAUSE,
],
];
/**
* Possible exceptions in SET statement.
*
* @var array<string, int|array<int, int|string>>
* @psalm-var array<string, (positive-int|array{positive-int, ('var'|'var='|'expr'|'expr=')})>
*/
public static array $statementOptions = [
'CHARSET' => [
3,
'var',
],
'CHARACTER SET' => [
3,
'var',
],
'NAMES' => [
3,
'var',
],
'PASSWORD' => [
3,
'expr',
],
'SESSION' => 3,
'GLOBAL' => 3,
'PERSIST' => 3,
'PERSIST_ONLY' => 3,
'@@SESSION' => 3,
'@@GLOBAL' => 3,
'@@PERSIST' => 3,
'@@PERSIST_ONLY' => 3,
];
protected const STATEMENT_END_OPTIONS = [
'COLLATE' => [
1,
'var',
],
'DEFAULT' => 1,
];
/**
* Options used in current statement.
*/
public OptionsArray|null $options = null;
/**
* The end options of this query.
*
* @see SetStatement::STATEMENT_END_OPTIONS
*/
public OptionsArray|null $endOptions = null;
/**
* The updated values.
*
* @var SetOperation[]|null
*/
public array|null $set = null;
public function build(): string
{
$ret = 'SET ' . $this->options->build()
. ' ' . SetOperations::buildAll($this->set)
. ' ' . ($this->endOptions?->build() ?? '');
return trim($ret);
}
}