1
|
|
|
<?php |
2
|
|
|
/* Copyright (C) NAVER <http://www.navercorp.com> */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* @author NAVER ([email protected]) |
6
|
|
|
* @package /classes/db/queryparts |
7
|
|
|
* @version 0.1 |
8
|
|
|
*/ |
9
|
|
|
class Query extends BaseObject |
10
|
|
|
{ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Query id, defined in query xml file |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
var $queryID; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* DML type, ex) INSERT, DELETE, UPDATE, SELECT |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
var $action; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* priority level ex)LOW_PRIORITY, HIGHT_PRIORITY |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
var $priority; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* column list |
32
|
|
|
* @var string|array |
33
|
|
|
*/ |
34
|
|
|
var $columns; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* table list |
38
|
|
|
* @var string|array |
39
|
|
|
*/ |
40
|
|
|
var $tables; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* condition list |
44
|
|
|
* @var string|array |
45
|
|
|
*/ |
46
|
|
|
var $conditions; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* group list |
50
|
|
|
* @var string|array |
51
|
|
|
*/ |
52
|
|
|
var $groups; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* order list |
56
|
|
|
* @var array |
57
|
|
|
*/ |
58
|
|
|
var $orderby; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* limit count |
62
|
|
|
* @var int |
63
|
|
|
*/ |
64
|
|
|
var $limit; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* argument list |
68
|
|
|
* @var array |
69
|
|
|
*/ |
70
|
|
|
var $arguments = NULL; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* column list |
74
|
|
|
* @var array |
75
|
|
|
*/ |
76
|
|
|
var $columnList = NULL; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* order by text |
80
|
|
|
* @var string |
81
|
|
|
*/ |
82
|
|
|
var $_orderByString; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* constructor |
86
|
|
|
* @param string $queryID |
87
|
|
|
* @param string $action |
88
|
|
|
* @param string|array $columns |
89
|
|
|
* @param string|array $tables |
90
|
|
|
* @param string|array $conditions |
91
|
|
|
* @param string|array $groups |
92
|
|
|
* @param string|array $orderby |
93
|
|
|
* @param int $limit |
94
|
|
|
* @param string $priority |
95
|
|
|
* @return void |
|
|
|
|
96
|
|
|
*/ |
97
|
|
|
function __construct($queryID = NULL |
98
|
|
|
, $action = NULL |
99
|
|
|
, $columns = NULL |
100
|
|
|
, $tables = NULL |
101
|
|
|
, $conditions = NULL |
102
|
|
|
, $groups = NULL |
103
|
|
|
, $orderby = NULL |
104
|
|
|
, $limit = NULL |
105
|
|
|
, $priority = NULL) |
106
|
|
|
{ |
107
|
|
|
$this->queryID = $queryID; |
108
|
|
|
$this->action = $action; |
109
|
|
|
$this->priority = $priority; |
110
|
|
|
|
111
|
|
|
if(!isset($tables)) |
112
|
|
|
{ |
113
|
|
|
return; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
$this->columns = $this->setColumns($columns); |
|
|
|
|
117
|
|
|
$this->tables = $this->setTables($tables); |
|
|
|
|
118
|
|
|
$this->conditions = $this->setConditions($conditions); |
|
|
|
|
119
|
|
|
$this->groups = $this->setGroups($groups); |
|
|
|
|
120
|
|
|
$this->orderby = $this->setOrder($orderby); |
|
|
|
|
121
|
|
|
$this->limit = $this->setLimit($limit); |
|
|
|
|
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
function show() |
125
|
|
|
{ |
126
|
|
|
return TRUE; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
function setQueryId($queryID) |
130
|
|
|
{ |
131
|
|
|
$this->queryID = $queryID; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
function setAction($action) |
135
|
|
|
{ |
136
|
|
|
$this->action = $action; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
function setPriority($priority) |
140
|
|
|
{ |
141
|
|
|
$this->priority = $priority; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
function setColumnList($columnList) |
145
|
|
|
{ |
146
|
|
|
$this->columnList = $columnList; |
147
|
|
|
if(is_array($this->columnList) && count($this->columnList) > 0) |
148
|
|
|
{ |
149
|
|
|
$selectColumns = array(); |
150
|
|
|
$dbParser = DB::getParser(); |
151
|
|
|
|
152
|
|
|
foreach($this->columnList as $columnName) |
153
|
|
|
{ |
154
|
|
|
$columnName = $dbParser->escapeColumn($columnName); |
155
|
|
|
$selectColumns[] = new SelectExpression($columnName); |
156
|
|
|
} |
157
|
|
|
unset($this->columns); |
158
|
|
|
$this->columns = $selectColumns; |
159
|
|
|
} |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
function setColumns($columns) |
163
|
|
|
{ |
164
|
|
|
if(!isset($columns) || (is_array($columns) && count($columns) === 0)) |
165
|
|
|
{ |
166
|
|
|
$this->columns = array(new StarExpression()); |
167
|
|
|
return; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
if(!is_array($columns)) |
171
|
|
|
{ |
172
|
|
|
$columns = array($columns); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
$this->columns = $columns; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
function setTables($tables) |
179
|
|
|
{ |
180
|
|
|
if(!isset($tables) || (is_array($tables) && count($tables) === 0)) |
181
|
|
|
{ |
182
|
|
|
$this->setError(TRUE); |
|
|
|
|
183
|
|
|
$this->setMessage("You must provide at least one table for the query."); |
184
|
|
|
return; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
if(!is_array($tables)) |
188
|
|
|
{ |
189
|
|
|
$tables = array($tables); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
$this->tables = $tables; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
function setSubquery($subquery) |
196
|
|
|
{ |
197
|
|
|
$this->subquery = $subquery; |
|
|
|
|
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
function setConditions($conditions) |
201
|
|
|
{ |
202
|
|
|
$this->conditions = array(); |
203
|
|
|
if(!isset($conditions) || (is_array($conditions) && count($conditions) === 0)) |
204
|
|
|
{ |
205
|
|
|
return; |
206
|
|
|
} |
207
|
|
|
if(!is_array($conditions)) |
208
|
|
|
{ |
209
|
|
|
$conditions = array($conditions); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
foreach($conditions as $conditionGroup) |
213
|
|
|
{ |
214
|
|
|
if($conditionGroup->show()) |
215
|
|
|
{ |
216
|
|
|
$this->conditions[] = $conditionGroup; |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
|
221
|
|
View Code Duplication |
function setGroups($groups) |
|
|
|
|
222
|
|
|
{ |
223
|
|
|
if(!isset($groups) || (is_array($groups) && count($groups) === 0)) |
224
|
|
|
{ |
225
|
|
|
return; |
226
|
|
|
} |
227
|
|
|
if(!is_array($groups)) |
228
|
|
|
{ |
229
|
|
|
$groups = array($groups); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$this->groups = $groups; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
View Code Duplication |
function setOrder($order) |
|
|
|
|
236
|
|
|
{ |
237
|
|
|
if(!isset($order) || (is_array($order) && count($order) === 0)) |
238
|
|
|
{ |
239
|
|
|
return; |
240
|
|
|
} |
241
|
|
|
if(!is_array($order)) |
242
|
|
|
{ |
243
|
|
|
$order = array($order); |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
$this->orderby = $order; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
function getOrder() |
250
|
|
|
{ |
251
|
|
|
return $this->orderby; |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
function setLimit($limit = NULL) |
255
|
|
|
{ |
256
|
|
|
if(!isset($limit)) |
257
|
|
|
{ |
258
|
|
|
return; |
259
|
|
|
} |
260
|
|
|
$this->limit = $limit; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
// START Fluent interface |
264
|
|
|
/** |
265
|
|
|
* seleect set |
266
|
|
|
* @param string|array $columns |
267
|
|
|
* @return Query return Query instance |
268
|
|
|
*/ |
269
|
|
|
function select($columns = NULL) |
270
|
|
|
{ |
271
|
|
|
$this->action = 'select'; |
272
|
|
|
$this->setColumns($columns); |
273
|
|
|
return $this; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* from set |
278
|
|
|
* @param string|array $tables |
279
|
|
|
* @return Query return Query instance |
280
|
|
|
*/ |
281
|
|
|
function from($tables) |
282
|
|
|
{ |
283
|
|
|
$this->setTables($tables); |
284
|
|
|
return $this; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* where set |
289
|
|
|
* @param string|array $conditions |
290
|
|
|
* @return Query return Query instance |
291
|
|
|
*/ |
292
|
|
|
function where($conditions) |
293
|
|
|
{ |
294
|
|
|
$this->setConditions($conditions); |
295
|
|
|
return $this; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* groupBy set |
300
|
|
|
* @param string|array $groups |
301
|
|
|
* @return Query return Query instance |
302
|
|
|
*/ |
303
|
|
|
function groupBy($groups) |
304
|
|
|
{ |
305
|
|
|
$this->setGroups($groups); |
306
|
|
|
return $this; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* orderBy set |
311
|
|
|
* @param string|array $order |
312
|
|
|
* @return Query return Query instance |
313
|
|
|
*/ |
314
|
|
|
function orderBy($order) |
315
|
|
|
{ |
316
|
|
|
$this->setOrder($order); |
317
|
|
|
return $this; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* limit set |
322
|
|
|
* @param int $limit |
323
|
|
|
* @return Query return Query instance |
324
|
|
|
*/ |
325
|
|
|
function limit($limit) |
326
|
|
|
{ |
327
|
|
|
$this->setLimit($limit); |
328
|
|
|
return $this; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
// END Fluent interface |
332
|
|
|
|
333
|
|
|
function getAction() |
334
|
|
|
{ |
335
|
|
|
return $this->action; |
336
|
|
|
} |
337
|
|
|
|
338
|
|
|
function getPriority() |
339
|
|
|
{ |
340
|
|
|
return $this->priority ? 'LOW_PRIORITY' : ''; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Check if current query uses the click count attribute |
345
|
|
|
* For CUBRID, this statement uses the click count feature. |
346
|
|
|
* For the other databases, using this attribute causes a query |
347
|
|
|
* to produce both a select and an update |
348
|
|
|
*/ |
349
|
|
|
function usesClickCount() |
350
|
|
|
{ |
351
|
|
|
return count($this->getClickCountColumns()) > 0; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
function getClickCountColumns() |
355
|
|
|
{ |
356
|
|
|
$click_count_columns = array(); |
357
|
|
|
foreach($this->columns as $column) |
|
|
|
|
358
|
|
|
{ |
359
|
|
|
if($column->show() && is_a($column, 'ClickCountExpression')) |
360
|
|
|
{ |
361
|
|
|
$click_count_columns[] = $column; |
362
|
|
|
} |
363
|
|
|
} |
364
|
|
|
return $click_count_columns; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Return select sql |
369
|
|
|
* @param boolean $with_values |
370
|
|
|
* @return string |
371
|
|
|
*/ |
372
|
|
|
function getSelectString($with_values = TRUE) |
373
|
|
|
{ |
374
|
|
|
foreach($this->columns as $column) |
|
|
|
|
375
|
|
|
{ |
376
|
|
|
if($column->show()) |
377
|
|
|
{ |
378
|
|
|
if($column->isSubquery()) |
379
|
|
|
{ |
380
|
|
|
$select[] = $column->toString($with_values) . ' as ' . $column->getAlias(); |
|
|
|
|
381
|
|
|
} |
382
|
|
|
else |
383
|
|
|
{ |
384
|
|
|
$select[] = $column->getExpression($with_values); |
|
|
|
|
385
|
|
|
} |
386
|
|
|
} |
387
|
|
|
} |
388
|
|
|
return trim(implode($select, ', ')); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Return update sql |
393
|
|
|
* @param boolean $with_values |
394
|
|
|
* @return string |
395
|
|
|
*/ |
396
|
|
|
function getUpdateString($with_values = TRUE) |
397
|
|
|
{ |
398
|
|
|
foreach($this->columns as $column) |
|
|
|
|
399
|
|
|
{ |
400
|
|
|
if($column->show()) |
401
|
|
|
{ |
402
|
|
|
$update[] = $column->getExpression($with_values); |
|
|
|
|
403
|
|
|
} |
404
|
|
|
} |
405
|
|
|
|
406
|
|
|
if(!$update) return; |
|
|
|
|
407
|
|
|
return trim(implode($update, ', ')); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* Return insert sql |
412
|
|
|
* @param boolean $with_values |
413
|
|
|
* @return string |
414
|
|
|
*/ |
415
|
|
|
function getInsertString($with_values = TRUE) |
416
|
|
|
{ |
417
|
|
|
$columnsList = ''; |
418
|
|
|
// means we have insert-select |
419
|
|
|
if($this->subquery) |
420
|
|
|
{ |
421
|
|
|
foreach($this->columns as $column) |
|
|
|
|
422
|
|
|
{ |
423
|
|
|
$columnsList .= $column->getColumnName() . ', '; |
424
|
|
|
} |
425
|
|
|
$columnsList = substr($columnsList, 0, -2); |
426
|
|
|
$selectStatement = $this->subquery->toString($with_values); |
427
|
|
|
$selectStatement = substr($selectStatement, 1, -1); |
428
|
|
|
return "($columnsList) \n $selectStatement"; |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
$valuesList = ''; |
432
|
|
|
foreach($this->columns as $column) |
|
|
|
|
433
|
|
|
{ |
434
|
|
|
if($column->show()) |
435
|
|
|
{ |
436
|
|
|
$columnsList .= $column->getColumnName() . ', '; |
437
|
|
|
$valuesList .= $column->getValue($with_values) . ', '; |
438
|
|
|
} |
439
|
|
|
} |
440
|
|
|
$columnsList = substr($columnsList, 0, -2); |
441
|
|
|
$valuesList = substr($valuesList, 0, -2); |
442
|
|
|
|
443
|
|
|
return "($columnsList) \n VALUES ($valuesList)"; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
function getTables() |
447
|
|
|
{ |
448
|
|
|
return $this->tables; |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* from table_a |
453
|
|
|
* from table_a inner join table_b on x=y |
454
|
|
|
* from (select * from table a) as x |
455
|
|
|
* from (select * from table t) as x inner join table y on y.x |
456
|
|
|
* @param boolean $with_values |
457
|
|
|
* @return string |
458
|
|
|
*/ |
459
|
|
|
function getFromString($with_values = TRUE) |
460
|
|
|
{ |
461
|
|
|
$from = ''; |
462
|
|
|
$simple_table_count = 0; |
463
|
|
|
foreach($this->tables as $table) |
|
|
|
|
464
|
|
|
{ |
465
|
|
|
if($table->isJoinTable() || !$simple_table_count) |
466
|
|
|
{ |
467
|
|
|
$from .= $table->toString($with_values) . ' '; |
468
|
|
|
} |
469
|
|
|
else |
470
|
|
|
{ |
471
|
|
|
$from .= ', ' . $table->toString($with_values) . ' '; |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
if(is_a($table, 'Subquery')) |
475
|
|
|
{ |
476
|
|
|
$from .= $table->getAlias() ? ' as ' . $table->getAlias() . ' ' : ' '; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
$simple_table_count++; |
480
|
|
|
} |
481
|
|
|
if(trim($from) == '') |
482
|
|
|
{ |
483
|
|
|
return ''; |
484
|
|
|
} |
485
|
|
|
return $from; |
486
|
|
|
} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* Return where sql |
490
|
|
|
* @param boolean $with_values |
491
|
|
|
* @param boolean $with_optimization |
492
|
|
|
* @return string |
493
|
|
|
*/ |
494
|
|
|
function getWhereString($with_values = TRUE, $with_optimization = TRUE) |
495
|
|
|
{ |
496
|
|
|
$where = ''; |
497
|
|
|
$condition_count = 0; |
498
|
|
|
|
499
|
|
|
foreach($this->conditions as $conditionGroup) |
|
|
|
|
500
|
|
|
{ |
501
|
|
|
if($condition_count === 0) |
502
|
|
|
{ |
503
|
|
|
$conditionGroup->setPipe(""); |
504
|
|
|
} |
505
|
|
|
$condition_string = $conditionGroup->toString($with_values); |
506
|
|
|
$where .= $condition_string; |
507
|
|
|
$condition_count++; |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
if($with_optimization && |
511
|
|
|
(strstr($this->getOrderByString(), 'list_order') || strstr($this->getOrderByString(), 'update_order'))) |
512
|
|
|
{ |
513
|
|
|
|
514
|
|
|
if($condition_count !== 0) |
515
|
|
|
{ |
516
|
|
|
$where = '(' . $where . ') '; |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
foreach($this->orderby as $order) |
520
|
|
|
{ |
521
|
|
|
$colName = $order->getColumnName(); |
522
|
|
|
if(strstr($colName, 'list_order') || strstr($colName, 'update_order')) |
523
|
|
|
{ |
524
|
|
|
$opt_condition = new ConditionWithoutArgument($colName, 2100000000, 'less', 'and'); |
525
|
|
|
if($condition_count === 0) |
526
|
|
|
{ |
527
|
|
|
$opt_condition->setPipe(""); |
528
|
|
|
} |
529
|
|
|
$where .= $opt_condition->toString($with_values) . ' '; |
530
|
|
|
$condition_count++; |
531
|
|
|
} |
532
|
|
|
} |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
return trim($where); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
/** |
539
|
|
|
* Return groupby sql |
540
|
|
|
* @return string |
541
|
|
|
*/ |
542
|
|
|
function getGroupByString() |
543
|
|
|
{ |
544
|
|
|
$groupBy = ''; |
545
|
|
|
if($this->groups) |
546
|
|
|
{ |
547
|
|
|
if($this->groups[0] !== "") |
548
|
|
|
{ |
549
|
|
|
$groupBy = implode(', ', $this->groups); |
550
|
|
|
} |
551
|
|
|
} |
552
|
|
|
return $groupBy; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* Return orderby sql |
557
|
|
|
* @return string |
558
|
|
|
*/ |
559
|
|
|
function getOrderByString() |
560
|
|
|
{ |
561
|
|
|
if(!$this->_orderByString) |
562
|
|
|
{ |
563
|
|
|
if(!is_array($this->orderby) || count($this->orderby) === 0) |
564
|
|
|
{ |
565
|
|
|
return ''; |
566
|
|
|
} |
567
|
|
|
$orderBy = ''; |
568
|
|
|
foreach($this->orderby as $order) |
569
|
|
|
{ |
570
|
|
|
$orderBy .= $order->toString() . ', '; |
571
|
|
|
} |
572
|
|
|
$orderBy = substr($orderBy, 0, -2); |
573
|
|
|
$this->_orderByString = $orderBy; |
574
|
|
|
} |
575
|
|
|
return $this->_orderByString; |
576
|
|
|
} |
577
|
|
|
|
578
|
|
|
function getLimit() |
579
|
|
|
{ |
580
|
|
|
return $this->limit; |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
/** |
584
|
|
|
* Return limit sql |
585
|
|
|
* @return string |
586
|
|
|
*/ |
587
|
|
|
function getLimitString() |
588
|
|
|
{ |
589
|
|
|
$limit = ''; |
590
|
|
|
if($this->limit) |
591
|
|
|
{ |
592
|
|
|
$limit = ''; |
593
|
|
|
$limit .= $this->limit->toString(); |
|
|
|
|
594
|
|
|
} |
595
|
|
|
return $limit; |
596
|
|
|
} |
597
|
|
|
|
598
|
|
|
function getFirstTableName() |
599
|
|
|
{ |
600
|
|
|
return $this->tables[0]->getName(); |
601
|
|
|
} |
602
|
|
|
|
603
|
|
|
/** |
604
|
|
|
* Return argument list |
605
|
|
|
* @return array |
606
|
|
|
*/ |
607
|
|
|
function getArguments() |
608
|
|
|
{ |
609
|
|
|
if(!isset($this->arguments)) |
610
|
|
|
{ |
611
|
|
|
$this->arguments = array(); |
612
|
|
|
|
613
|
|
|
// Join table arguments |
614
|
|
View Code Duplication |
if(is_array($this->tables) && count($this->tables) > 0) |
615
|
|
|
{ |
616
|
|
|
foreach($this->tables as $table) |
617
|
|
|
{ |
618
|
|
|
if($table->isJoinTable() || is_a($table, 'Subquery')) |
619
|
|
|
{ |
620
|
|
|
$args = $table->getArguments(); |
621
|
|
|
if($args) |
622
|
|
|
{ |
623
|
|
|
$this->arguments = array_merge($this->arguments, $args); |
624
|
|
|
} |
625
|
|
|
} |
626
|
|
|
} |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
// Column arguments |
630
|
|
|
// The if is for delete statements, all others must have columns |
631
|
|
View Code Duplication |
if(is_array($this->columns) && count($this->columns) > 0) |
632
|
|
|
{ |
633
|
|
|
foreach($this->columns as $column) |
634
|
|
|
{ |
635
|
|
|
if($column->show()) |
636
|
|
|
{ |
637
|
|
|
$args = $column->getArguments(); |
638
|
|
|
if($args) |
639
|
|
|
{ |
640
|
|
|
$this->arguments = array_merge($this->arguments, $args); |
641
|
|
|
} |
642
|
|
|
} |
643
|
|
|
} |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
// Condition arguments |
647
|
|
View Code Duplication |
if(is_array($this->conditions) && count($this->conditions) > 0) |
648
|
|
|
{ |
649
|
|
|
foreach($this->conditions as $conditionGroup) |
650
|
|
|
{ |
651
|
|
|
$args = $conditionGroup->getArguments(); |
652
|
|
|
if(count($args) > 0) |
653
|
|
|
{ |
654
|
|
|
$this->arguments = array_merge($this->arguments, $args); |
655
|
|
|
} |
656
|
|
|
} |
657
|
|
|
} |
658
|
|
|
|
659
|
|
|
// Navigation arguments |
660
|
|
View Code Duplication |
if(is_array($this->orderby) && count($this->orderby) > 0) |
661
|
|
|
{ |
662
|
|
|
foreach($this->orderby as $order) |
663
|
|
|
{ |
664
|
|
|
$args = $order->getArguments(); |
665
|
|
|
if(count($args) > 0) |
666
|
|
|
{ |
667
|
|
|
$this->arguments = array_merge($this->arguments, $args); |
668
|
|
|
} |
669
|
|
|
} |
670
|
|
|
} |
671
|
|
|
} |
672
|
|
|
return $this->arguments; |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
} |
676
|
|
|
/* End of file Query.class.php */ |
677
|
|
|
/* Location: ./classes/db/queryparts/Query.class.php */ |
678
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.