1 | <?php |
||
51 | class SelectStatement extends Statement |
||
52 | { |
||
53 | /** |
||
54 | * Options for `SELECT` statements and their slot ID. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | public static $OPTIONS = array( |
||
59 | 'ALL' => 1, |
||
60 | 'DISTINCT' => 1, |
||
61 | 'DISTINCTROW' => 1, |
||
62 | 'HIGH_PRIORITY' => 2, |
||
63 | 'MAX_STATEMENT_TIME' => array(3, 'var='), |
||
64 | 'STRAIGHT_JOIN' => 4, |
||
65 | 'SQL_SMALL_RESULT' => 5, |
||
66 | 'SQL_BIG_RESULT' => 6, |
||
67 | 'SQL_BUFFER_RESULT' => 7, |
||
68 | 'SQL_CACHE' => 8, |
||
69 | 'SQL_NO_CACHE' => 8, |
||
70 | 'SQL_CALC_FOUND_ROWS' => 9, |
||
71 | ); |
||
72 | |||
73 | public static $END_OPTIONS = array( |
||
74 | 'FOR UPDATE' => 1, |
||
75 | 'LOCK IN SHARE MODE' => 1, |
||
76 | ); |
||
77 | |||
78 | /** |
||
79 | * The clauses of this statement, in order. |
||
80 | * |
||
81 | * @see Statement::$CLAUSES |
||
82 | * |
||
83 | * @var array |
||
84 | */ |
||
85 | public static $CLAUSES = array( |
||
86 | 'SELECT' => array('SELECT', 2), |
||
87 | // Used for options. |
||
88 | '_OPTIONS' => array('_OPTIONS', 1), |
||
89 | // Used for selected expressions. |
||
90 | '_SELECT' => array('SELECT', 1), |
||
91 | 'INTO' => array('INTO', 3), |
||
92 | 'FROM' => array('FROM', 3), |
||
93 | 'PARTITION' => array('PARTITION', 3), |
||
94 | |||
95 | 'JOIN' => array('JOIN', 1), |
||
96 | 'FULL JOIN' => array('FULL JOIN', 1), |
||
97 | 'INNER JOIN' => array('INNER JOIN', 1), |
||
98 | 'LEFT JOIN' => array('LEFT JOIN', 1), |
||
99 | 'LEFT OUTER JOIN' => array('LEFT OUTER JOIN', 1), |
||
100 | 'RIGHT JOIN' => array('RIGHT JOIN', 1), |
||
101 | 'RIGHT OUTER JOIN' => array('RIGHT OUTER JOIN', 1), |
||
102 | 'NATURAL JOIN' => array('NATURAL JOIN', 1), |
||
103 | 'NATURAL LEFT JOIN' => array('NATURAL LEFT JOIN', 1), |
||
104 | 'NATURAL RIGHT JOIN' => array('NATURAL RIGHT JOIN', 1), |
||
105 | 'NATURAL LEFT OUTER JOIN' => array('NATURAL LEFT OUTER JOIN', 1), |
||
106 | 'NATURAL RIGHT OUTER JOIN' => array('NATURAL RIGHT JOIN', 1), |
||
107 | |||
108 | 'WHERE' => array('WHERE', 3), |
||
109 | 'GROUP BY' => array('GROUP BY', 3), |
||
110 | 'HAVING' => array('HAVING', 3), |
||
111 | 'ORDER BY' => array('ORDER BY', 3), |
||
112 | 'LIMIT' => array('LIMIT', 3), |
||
113 | 'PROCEDURE' => array('PROCEDURE', 3), |
||
114 | 'UNION' => array('UNION', 1), |
||
115 | '_END_OPTIONS' => array('_END_OPTIONS', 1), |
||
116 | // These are available only when `UNION` is present. |
||
117 | // 'ORDER BY' => array('ORDER BY', 3), |
||
118 | // 'LIMIT' => array('LIMIT', 3), |
||
119 | ); |
||
120 | |||
121 | /** |
||
122 | * Expressions that are being selected by this statement. |
||
123 | * |
||
124 | * @var Expression[] |
||
125 | */ |
||
126 | public $expr = array(); |
||
127 | |||
128 | /** |
||
129 | * Tables used as sources for this statement. |
||
130 | * |
||
131 | * @var Expression[] |
||
132 | */ |
||
133 | public $from = array(); |
||
134 | |||
135 | /** |
||
136 | * Partitions used as source for this statement. |
||
137 | * |
||
138 | * @var ArrayObj |
||
139 | */ |
||
140 | public $partition; |
||
141 | |||
142 | /** |
||
143 | * Conditions used for filtering each row of the result set. |
||
144 | * |
||
145 | * @var Condition[] |
||
146 | */ |
||
147 | public $where; |
||
148 | |||
149 | /** |
||
150 | * Conditions used for grouping the result set. |
||
151 | * |
||
152 | * @var OrderKeyword[] |
||
153 | */ |
||
154 | public $group; |
||
155 | |||
156 | /** |
||
157 | * Conditions used for filtering the result set. |
||
158 | * |
||
159 | * @var Condition[] |
||
160 | */ |
||
161 | public $having; |
||
162 | |||
163 | /** |
||
164 | * Specifies the order of the rows in the result set. |
||
165 | * |
||
166 | * @var OrderKeyword[] |
||
167 | */ |
||
168 | public $order; |
||
169 | |||
170 | /** |
||
171 | * Conditions used for limiting the size of the result set. |
||
172 | * |
||
173 | * @var Limit |
||
174 | */ |
||
175 | public $limit; |
||
176 | |||
177 | /** |
||
178 | * Procedure that should process the data in the result set. |
||
179 | * |
||
180 | * @var FunctionCall |
||
181 | */ |
||
182 | public $procedure; |
||
183 | |||
184 | /** |
||
185 | * Destination of this result set. |
||
186 | * |
||
187 | * @var IntoKeyword |
||
188 | */ |
||
189 | public $into; |
||
190 | |||
191 | /** |
||
192 | * Joins. |
||
193 | * |
||
194 | * @var JoinKeyword[] |
||
195 | */ |
||
196 | public $join; |
||
197 | |||
198 | /** |
||
199 | * Unions. |
||
200 | * |
||
201 | * @var SelectStatement[] |
||
202 | */ |
||
203 | public $union = array(); |
||
204 | |||
205 | /** |
||
206 | * The end options of this query. |
||
207 | * |
||
208 | * @var OptionsArray |
||
209 | * |
||
210 | * @see static::$END_OPTIONS |
||
211 | */ |
||
212 | public $end_options; |
||
213 | |||
214 | /** |
||
215 | * Gets the clauses of this statement. |
||
216 | * |
||
217 | * @return array |
||
218 | */ |
||
219 | 95 | public function getClauses() |
|
236 | } |
||
237 |