@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * Construct new data manager |
29 | 29 | * |
30 | 30 | * @param string $modelName |
31 | - * @param string|array $dataManager |
|
31 | + * @param string $dataManager |
|
32 | 32 | * @throws Exception |
33 | 33 | */ |
34 | 34 | public function __construct($modelName, $dataManager = 'manager') |
@@ -330,6 +330,9 @@ discard block |
||
330 | 330 | return $rows; |
331 | 331 | } |
332 | 332 | |
333 | + /** |
|
334 | + * @param DataManager $dataManager |
|
335 | + */ |
|
333 | 336 | public static function drawCol($item, $colName, $params = [], $dataManager = null, $originalCol = '', $originalItem = null) |
334 | 337 | { |
335 | 338 | $modelName = get_class($item); |
@@ -126,12 +126,14 @@ discard block |
||
126 | 126 | if (!is_array($order)) { |
127 | 127 | $this->order[] = "{$order} {$type}"; |
128 | 128 | } else { |
129 | - foreach ($order as $item) |
|
130 | - if (!is_array($item)) { |
|
129 | + foreach ($order as $item) { |
|
130 | + if (!is_array($item)) { |
|
131 | 131 | call_user_func_array(array($this, 'order'), $order); |
132 | + } |
|
132 | 133 | break; |
133 | - } else |
|
134 | - $this->order($item); |
|
134 | + } else { |
|
135 | + $this->order($item); |
|
136 | + } |
|
135 | 137 | } |
136 | 138 | } |
137 | 139 | |
@@ -140,8 +142,9 @@ discard block |
||
140 | 142 | $start = intval($start); |
141 | 143 | $len = intval($len); |
142 | 144 | $this->limit = "LIMIT {$start}"; |
143 | - if ($len !== 0) |
|
144 | - $this->limit .= ",{$len}"; |
|
145 | + if ($len !== 0) { |
|
146 | + $this->limit .= ",{$len}"; |
|
147 | + } |
|
145 | 148 | } |
146 | 149 | |
147 | 150 | public function buildJoin($table, $where = false, $type = 'LEFT', $alias = '') |
@@ -154,10 +157,12 @@ discard block |
||
154 | 157 | } |
155 | 158 | } else { |
156 | 159 | $join .= " {$type} JOIN {$this->curInstance->table_prefix}{$table}"; |
157 | - if ($alias) |
|
158 | - $join .= " AS `{$alias}`"; |
|
159 | - if ($where) |
|
160 | - $join .= " ON {$where}"; |
|
160 | + if ($alias) { |
|
161 | + $join .= " AS `{$alias}`"; |
|
162 | + } |
|
163 | + if ($where) { |
|
164 | + $join .= " ON {$where}"; |
|
165 | + } |
|
161 | 166 | } |
162 | 167 | return $join; |
163 | 168 | } |
@@ -177,31 +182,33 @@ discard block |
||
177 | 182 | $operation = '='; |
178 | 183 | } |
179 | 184 | |
180 | - if ($concatenation === false) |
|
181 | - $concatenation = 'AND'; |
|
182 | - elseif ($concatenation === true) |
|
183 | - $concatenation = ''; |
|
185 | + if ($concatenation === false) { |
|
186 | + $concatenation = 'AND'; |
|
187 | + } elseif ($concatenation === true) { |
|
188 | + $concatenation = ''; |
|
189 | + } |
|
184 | 190 | |
185 | - if ($this->whereString == NULL) |
|
186 | - $this->whereString = ' WHERE '; |
|
191 | + if ($this->whereString == NULL) { |
|
192 | + $this->whereString = ' WHERE '; |
|
193 | + } |
|
187 | 194 | |
188 | 195 | if (stristr($operation, 'IN') || stristr($operation, 'NOT IN')) { |
189 | - if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) |
|
190 | - $value = "({$value})"; |
|
191 | - elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) |
|
192 | - $value = "\"{$value}\""; |
|
193 | - } |
|
194 | - elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
196 | + if (!preg_match('!\(!', $value) && !preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
197 | + $value = "({$value})"; |
|
198 | + } elseif (preg_match('!\(!', $value) && preg_match('![^0-9,\.\(\) ]!', $value)) { |
|
199 | + $value = "\"{$value}\""; |
|
200 | + } |
|
201 | + } elseif (!in_array($value, array('CURRENT_TIMESTAMP'))) { |
|
195 | 202 | $this->params[] = $value; |
196 | 203 | $value = "?"; |
197 | 204 | } |
198 | 205 | |
199 | - if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') |
|
200 | - $this->whereString .= " {$where} {$operation} {$value} "; |
|
201 | - else |
|
202 | - $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
203 | - } |
|
204 | - else { |
|
206 | + if (substr($this->whereString, -1, 1) == '(' || substr($this->whereString, -2, 2) == 'E ') { |
|
207 | + $this->whereString .= " {$where} {$operation} {$value} "; |
|
208 | + } else { |
|
209 | + $this->whereString .= "{$concatenation} {$where} {$operation} {$value} "; |
|
210 | + } |
|
211 | + } else { |
|
205 | 212 | $i = -1; |
206 | 213 | while (isset($where[++$i])) { |
207 | 214 | $item = $where[$i]; |
@@ -216,28 +223,32 @@ discard block |
||
216 | 223 | $this->whereString .= "{$concatenation} "; |
217 | 224 | } |
218 | 225 | |
219 | - if ($this->whereString != NULL) |
|
220 | - $this->whereString .= '('; |
|
221 | - else |
|
222 | - $this->whereString = 'WHERE ('; |
|
226 | + if ($this->whereString != NULL) { |
|
227 | + $this->whereString .= '('; |
|
228 | + } else { |
|
229 | + $this->whereString = 'WHERE ('; |
|
230 | + } |
|
223 | 231 | } |
224 | 232 | |
225 | 233 | if (!is_array($item)) { |
226 | 234 | call_user_func_array(array($this, 'buildWhere'), $where); |
227 | 235 | break; |
228 | 236 | } else { |
229 | - if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') |
|
230 | - if (!isset($item[3])) |
|
237 | + if ($this->whereString != NULL && substr($this->whereString, -1, 1) != '(') { |
|
238 | + if (!isset($item[3])) |
|
231 | 239 | $concatenation = 'AND'; |
232 | - else |
|
233 | - $concatenation = $item[3]; |
|
234 | - elseif (substr($this->whereString, -1, 1) != '(') |
|
235 | - $this->whereString = 'WHERE '; |
|
240 | + } else { |
|
241 | + $concatenation = $item[3]; |
|
242 | + } |
|
243 | + elseif (substr($this->whereString, -1, 1) != '(') { |
|
244 | + $this->whereString = 'WHERE '; |
|
245 | + } |
|
236 | 246 | |
237 | 247 | $this->buildWhere($item); |
238 | 248 | } |
239 | - if (!isset($where[$i + 1]) && isset($where[$i - 1])) |
|
240 | - $this->whereString .= ') '; |
|
249 | + if (!isset($where[$i + 1]) && isset($where[$i - 1])) { |
|
250 | + $this->whereString .= ') '; |
|
251 | + } |
|
241 | 252 | } |
242 | 253 | } |
243 | 254 | } |