1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ps2alerts\Api\QueryObjects; |
4
|
|
|
|
5
|
|
|
class QueryObject |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var array |
9
|
|
|
*/ |
10
|
|
|
protected $selects; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var array |
14
|
|
|
*/ |
15
|
|
|
protected $wheres; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var array |
19
|
|
|
*/ |
20
|
|
|
protected $whereIns; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $orderBy; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
protected $orderByDirection = 'asc'; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $dimension = 'multi'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Limit of records to bring back |
39
|
|
|
* |
40
|
|
|
* @var integer |
41
|
|
|
*/ |
42
|
|
|
protected $limit = null; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Place to set special workaround flags |
46
|
|
|
* |
47
|
|
|
* @var string|array |
48
|
|
|
*/ |
49
|
|
|
protected $flags; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Adds select statement parameters to the object |
53
|
|
|
* Expects a string column name, which is then looped through |
54
|
|
|
* in the array and added to. |
55
|
|
|
* e.g. $queryObject->addSelect('COUNT(ResultID) AS COUNT'); |
56
|
|
|
* |
57
|
|
|
* @param string $string |
|
|
|
|
58
|
|
|
*/ |
59
|
|
|
public function addSelect($array) |
60
|
|
|
{ |
61
|
|
|
$this->selects[] = $array; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Gets the select statement parameters out of the object |
66
|
|
|
* |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public function getSelects() |
70
|
|
|
{ |
71
|
|
|
return $this->selects; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Adds where statements to the object |
76
|
|
|
* |
77
|
|
|
* @param array $array |
78
|
|
|
*/ |
79
|
|
|
public function addWhere(array $array) |
80
|
|
|
{ |
81
|
|
|
$this->wheres[] = $array; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Pulls out the array for the where statements |
86
|
|
|
* |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function getWheres() |
90
|
|
|
{ |
91
|
|
|
return $this->wheres; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Adds where statements to the object |
96
|
|
|
* |
97
|
|
|
* @param array $array |
98
|
|
|
*/ |
99
|
|
|
public function addWhereIn(array $array) |
100
|
|
|
{ |
101
|
|
|
$this->whereIns[] = $array; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Pulls out the array for the where statements |
106
|
|
|
* |
107
|
|
|
* @return array |
108
|
|
|
*/ |
109
|
|
|
public function getWhereIns() |
110
|
|
|
{ |
111
|
|
|
return $this->whereIns; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Set order by column |
116
|
|
|
* |
117
|
|
|
* @param string $string [description] |
118
|
|
|
*/ |
119
|
|
|
public function setOrderBy($string) |
120
|
|
|
{ |
121
|
|
|
if (! empty($string)) { |
122
|
|
|
$this->orderBy = $string; |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Get order by column |
128
|
|
|
* |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getOrderBy() |
132
|
|
|
{ |
133
|
|
|
return $this->orderBy; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Set asc or desc |
138
|
|
|
* |
139
|
|
|
* @param string $string |
140
|
|
|
*/ |
141
|
|
|
public function setOrderByDirection($string) |
142
|
|
|
{ |
143
|
|
|
if (! empty($string)) { |
144
|
|
|
$this->orderByDirection = $string; |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Gets order by direction |
150
|
|
|
* |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public function getOrderByDirection() |
154
|
|
|
{ |
155
|
|
|
return $this->orderByDirection; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Set array dimension level |
160
|
|
|
* |
161
|
|
|
* @param string $string |
162
|
|
|
*/ |
163
|
|
|
public function setDimension($string) |
164
|
|
|
{ |
165
|
|
|
if (! empty($string)) { |
166
|
|
|
$this->dimension = $string; |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Gets array dimension level |
172
|
|
|
* |
173
|
|
|
* @return string |
174
|
|
|
*/ |
175
|
|
|
public function getDimension() |
176
|
|
|
{ |
177
|
|
|
return $this->dimension; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Sets the limit of records to bring back |
182
|
|
|
* |
183
|
|
|
* @param integer $limit |
184
|
|
|
*/ |
185
|
|
|
public function setLimit($limit) |
186
|
|
|
{ |
187
|
|
|
if (! empty($limit) && is_numeric($limit)) { |
188
|
|
|
$this->limit = $limit; |
|
|
|
|
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Gets the limit of records |
194
|
|
|
* |
195
|
|
|
* @return integer |
196
|
|
|
*/ |
197
|
|
|
public function getLimit() |
198
|
|
|
{ |
199
|
|
|
return $this->limit; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Allows setting of workaround flags |
204
|
|
|
* |
205
|
|
|
* @param array|string $flags |
206
|
|
|
*/ |
207
|
|
|
public function setFlags($flags) |
208
|
|
|
{ |
209
|
|
|
if (! empty($flags)) { |
210
|
|
|
$this->flags = $flags; |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Retreives workaround flags |
216
|
|
|
* |
217
|
|
|
* @return array|string |
218
|
|
|
*/ |
219
|
|
|
public function getFlags() |
220
|
|
|
{ |
221
|
|
|
return $this->flags; |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.