@@ -47,7 +47,7 @@ |
||
47 | 47 | $instance->setDefault($data['default']); |
48 | 48 | } |
49 | 49 | if ($instance->getBasicType() === 'enum' && strpos($instance->getType(), 'enum(') === 0) { |
50 | - $temp = array_map(function ($v) { |
|
50 | + $temp = array_map(function($v) { |
|
51 | 51 | return str_replace("''", "'", $v); |
52 | 52 | }, explode("','", substr($instance->getType(), 6, -2))); |
53 | 53 | $instance->setValues($temp); |
@@ -18,8 +18,7 @@ |
||
18 | 18 | $this->settings->password, |
19 | 19 | $this->settings->servername, |
20 | 20 | $this->settings->charset |
21 | - ) : |
|
22 | - @oci_connect( |
|
21 | + ) : @oci_connect( |
|
23 | 22 | $this->settings->username, |
24 | 23 | $this->settings->password, |
25 | 24 | $this->settings->servername, |
@@ -85,34 +85,34 @@ |
||
85 | 85 | foreach ($data as $i => $v) { |
86 | 86 | switch (gettype($v)) { |
87 | 87 | case 'boolean': |
88 | - $sql->bindValue($i+1, $v, \PDO::PARAM_BOOL); |
|
88 | + $sql->bindValue($i + 1, $v, \PDO::PARAM_BOOL); |
|
89 | 89 | break; |
90 | 90 | case 'integer': |
91 | - $sql->bindValue($i+1, $v, \PDO::PARAM_INT); |
|
91 | + $sql->bindValue($i + 1, $v, \PDO::PARAM_INT); |
|
92 | 92 | break; |
93 | 93 | case 'NULL': |
94 | - $sql->bindValue($i+1, $v, \PDO::PARAM_NULL); |
|
94 | + $sql->bindValue($i + 1, $v, \PDO::PARAM_NULL); |
|
95 | 95 | break; |
96 | 96 | case 'double': |
97 | - $sql->bindValue($i+1, $v); |
|
97 | + $sql->bindValue($i + 1, $v); |
|
98 | 98 | break; |
99 | 99 | default: |
100 | 100 | // keep in mind oracle needs a transaction when inserting LOBs, aside from the specific syntax: |
101 | 101 | // INSERT INTO table (column, lobcolumn) VALUES (?, ?, EMPTY_BLOB()) RETURNING lobcolumn INTO ? |
102 | 102 | if (is_resource($v) && get_resource_type($v) === 'stream') { |
103 | - $sql->bindParam($i+1, $v, \PDO::PARAM_LOB); |
|
103 | + $sql->bindParam($i + 1, $v, \PDO::PARAM_LOB); |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | if (!is_string($data[$i])) { |
107 | 107 | $data[$i] = serialize($data[$i]); |
108 | 108 | } |
109 | - $sql->bindValue($i+1, $v); |
|
109 | + $sql->bindValue($i + 1, $v); |
|
110 | 110 | break; |
111 | 111 | } |
112 | 112 | } |
113 | 113 | $rtrn = $sql->execute(); |
114 | 114 | if (!$rtrn) { |
115 | - throw new DatabaseException('Prepared execute error : '. implode(',', $sql->errorInfo())); |
|
115 | + throw new DatabaseException('Prepared execute error : '.implode(',', $sql->errorInfo())); |
|
116 | 116 | } |
117 | 117 | $this->aff = $sql->rowCount(); |
118 | 118 | return $sql->columnCount() ? $sql : $rtrn; |
@@ -27,8 +27,7 @@ discard block |
||
27 | 27 | 'password='.$this->settings->password.' '. |
28 | 28 | 'dbname='.$this->settings->database.' '. |
29 | 29 | "options='--client_encoding=".strtoupper($this->settings->charset)."' " |
30 | - ) : |
|
31 | - @pg_connect( |
|
30 | + ) : @pg_connect( |
|
32 | 31 | 'host='.$this->settings->servername.' '. |
33 | 32 | 'port='.$this->settings->serverport.' '. |
34 | 33 | 'user='.$this->settings->username.' '. |
@@ -78,8 +77,7 @@ discard block |
||
78 | 77 | $data = array(); |
79 | 78 | } |
80 | 79 | $temp = (is_array($data) && count($data)) ? |
81 | - pg_query_params($this->lnk, $sql, $data) : |
|
82 | - pg_query_params($this->lnk, $sql, array()); |
|
80 | + pg_query_params($this->lnk, $sql, $data) : pg_query_params($this->lnk, $sql, array()); |
|
83 | 81 | if (!$temp) { |
84 | 82 | throw new DatabaseException('Could not execute query : '.pg_last_error($this->lnk).' <'.$sql.'>'); |
85 | 83 | } |
@@ -23,8 +23,7 @@ |
||
23 | 23 | $this->settings->servername.':'.$this->settings->serverport, |
24 | 24 | $this->settings->username, |
25 | 25 | $this->settings->password |
26 | - ) : |
|
27 | - @mysql_connect( |
|
26 | + ) : @mysql_connect( |
|
28 | 27 | $this->settings->servername.':'.$this->settings->serverport, |
29 | 28 | $this->settings->username, |
30 | 29 | $this->settings->password |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | } |
18 | 18 | $this->settings->servername = |
19 | 19 | ($this->settings->servername === 'localhost' || $this->settings->servername === '') ? |
20 | - '' : |
|
21 | - $this->settings->servername.':'; |
|
20 | + '' : $this->settings->servername.':'; |
|
22 | 21 | } |
23 | 22 | protected function connect() |
24 | 23 | { |
@@ -29,8 +28,7 @@ discard block |
||
29 | 28 | $this->settings->username, |
30 | 29 | $this->settings->password, |
31 | 30 | strtoupper($this->settings->charset) |
32 | - ) : |
|
33 | - @\ibase_connect( |
|
31 | + ) : @\ibase_connect( |
|
34 | 32 | $this->settings->servername.$this->settings->database, |
35 | 33 | $this->settings->username, |
36 | 34 | $this->settings->password, |
@@ -102,8 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | } |
104 | 104 | $cnt = $this->mode === 'assoc_ci' ? |
105 | - count(array_unique(array_map('strtolower', array_keys($row)))) : |
|
106 | - count($row); |
|
105 | + count(array_unique(array_map('strtolower', array_keys($row)))) : count($row); |
|
107 | 106 | if ($this->opti && is_array($row) && $cnt <= 1) { |
108 | 107 | $row = count($row) ? current($row) : current($tmp); |
109 | 108 | } |
@@ -123,7 +122,7 @@ discard block |
||
123 | 122 | if ($this->rdy) { |
124 | 123 | return next($this->all); |
125 | 124 | } |
126 | - if($this->rslt->nextr()) { |
|
125 | + if ($this->rslt->nextr()) { |
|
127 | 126 | ++$this->realKey; |
128 | 127 | } |
129 | 128 | else { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function setPrimaryKey($column) : Table |
79 | 79 | { |
80 | 80 | if (!is_array($column)) { |
81 | - $column = [ $column ]; |
|
81 | + $column = [$column]; |
|
82 | 82 | } |
83 | 83 | $this->data['primary'] = $column; |
84 | 84 | return $this; |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | } |
166 | 166 | |
167 | 167 | if (!isset($name)) { |
168 | - $name = $toTable->getName() . '_' . implode('_', array_keys($keymap)); |
|
168 | + $name = $toTable->getName().'_'.implode('_', array_keys($keymap)); |
|
169 | 169 | } |
170 | 170 | $this->addRelation(new TableRelation( |
171 | 171 | $name, |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @var int[] |
40 | 40 | */ |
41 | - protected $li_of = [0,0]; |
|
41 | + protected $li_of = [0, 0]; |
|
42 | 42 | protected $fields = []; |
43 | 43 | /** |
44 | 44 | * @var array |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public function __construct(DatabaseInterface $db, $table) |
58 | 58 | { |
59 | 59 | $this->db = $db; |
60 | - $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table); |
|
60 | + $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table); |
|
61 | 61 | $this->columns($this->definition->getColumns()); |
62 | 62 | } |
63 | 63 | public function __clone() |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $column = explode('.', $column, 2); |
79 | 79 | if (count($column) === 1) { |
80 | - $column = [ $this->definition->getName(), $column[0] ]; |
|
80 | + $column = [$this->definition->getName(), $column[0]]; |
|
81 | 81 | } |
82 | 82 | if ($column[0] === $this->definition->getName()) { |
83 | 83 | $col = $this->definition->getColumn($column[1]); |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | throw new DatabaseException('Invalid column name in related table'); |
97 | 97 | } |
98 | 98 | } else { |
99 | - throw new DatabaseException('Invalid foreign table name: ' . implode(',', $column)); |
|
99 | + throw new DatabaseException('Invalid foreign table name: '.implode(',', $column)); |
|
100 | 100 | } |
101 | 101 | } |
102 | - return [ 'name' => implode('.', $column), 'data' => $col ]; |
|
102 | + return ['name' => implode('.', $column), 'data' => $col]; |
|
103 | 103 | } |
104 | 104 | protected function normalizeValue(TableColumn $col, $value) |
105 | 105 | { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | return $value; |
140 | 140 | case 'int': |
141 | - return (int)$value; |
|
141 | + return (int) $value; |
|
142 | 142 | default: |
143 | 143 | return $value; |
144 | 144 | } |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | { |
154 | 154 | list($name, $column) = array_values($this->getColumn($column)); |
155 | 155 | if (is_null($value)) { |
156 | - return $this->where($name . ' IS NULL'); |
|
156 | + return $this->where($name.' IS NULL'); |
|
157 | 157 | } |
158 | 158 | if (!is_array($value)) { |
159 | 159 | return $this->where( |
160 | - $name . ' = ?', |
|
161 | - [ $this->normalizeValue($column, $value) ] |
|
160 | + $name.' = ?', |
|
161 | + [$this->normalizeValue($column, $value)] |
|
162 | 162 | ); |
163 | 163 | } |
164 | 164 | if (isset($value['beg']) && isset($value['end'])) { |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | ); |
172 | 172 | } |
173 | 173 | return $this->where( |
174 | - $name . ' IN (??)', |
|
175 | - [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ] |
|
174 | + $name.' IN (??)', |
|
175 | + [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)] |
|
176 | 176 | ); |
177 | 177 | } |
178 | 178 | /** |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function sort(string $column, bool $desc = false) : TableQuery |
185 | 185 | { |
186 | - return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC')); |
|
186 | + return $this->order($this->getColumn($column)['name'].' '.($desc ? 'DESC' : 'ASC')); |
|
187 | 187 | } |
188 | 188 | /** |
189 | 189 | * Group by a column (or columns) |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | public function group($column) : TableQuery |
194 | 194 | { |
195 | 195 | if (!is_array($column)) { |
196 | - $column = [ $column ]; |
|
196 | + $column = [$column]; |
|
197 | 197 | } |
198 | 198 | foreach ($column as $k => $v) { |
199 | 199 | $column[$k] = $this->getColumn($v)['name']; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $this->withr = []; |
235 | 235 | $this->order = []; |
236 | 236 | $this->having = []; |
237 | - $this->li_of = [0,0]; |
|
237 | + $this->li_of = [0, 0]; |
|
238 | 238 | $this->qiterator = null; |
239 | 239 | return $this; |
240 | 240 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | public function groupBy(string $sql, array $params = []) : TableQuery |
248 | 248 | { |
249 | 249 | $this->qiterator = null; |
250 | - $this->group = [ $sql, $params ]; |
|
250 | + $this->group = [$sql, $params]; |
|
251 | 251 | return $this; |
252 | 252 | } |
253 | 253 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function join($table, array $fields, string $name = null, bool $multiple = true) |
262 | 262 | { |
263 | - $table = $table instanceof Table ? $table : $this->db->definition((string)$table); |
|
263 | + $table = $table instanceof Table ? $table : $this->db->definition((string) $table); |
|
264 | 264 | $name = $name ?? $table->getName(); |
265 | 265 | if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) { |
266 | 266 | throw new DatabaseException('Alias / table name already in use'); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | foreach ($fields as $k => $v) { |
270 | 270 | $k = explode('.', $k, 2); |
271 | 271 | $k = count($k) == 2 ? $k[1] : $k[0]; |
272 | - $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name']; |
|
272 | + $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name']; |
|
273 | 273 | } |
274 | 274 | return $this; |
275 | 275 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | public function where(string $sql, array $params = []) : TableQuery |
283 | 283 | { |
284 | 284 | $this->qiterator = null; |
285 | - $this->where[] = [ $sql, $params ]; |
|
285 | + $this->where[] = [$sql, $params]; |
|
286 | 286 | return $this; |
287 | 287 | } |
288 | 288 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | public function having(string $sql, array $params = []) : TableQuery |
295 | 295 | { |
296 | 296 | $this->qiterator = null; |
297 | - $this->having[] = [ $sql, $params ]; |
|
297 | + $this->having[] = [$sql, $params]; |
|
298 | 298 | return $this; |
299 | 299 | } |
300 | 300 | /** |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | public function order(string $sql, array $params = []) : TableQuery |
307 | 307 | { |
308 | 308 | $this->qiterator = null; |
309 | - $this->order = [ $sql, $params ]; |
|
309 | + $this->order = [$sql, $params]; |
|
310 | 310 | return $this; |
311 | 311 | } |
312 | 312 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | public function limit(int $limit, int $offset = 0) : TableQuery |
319 | 319 | { |
320 | 320 | $this->qiterator = null; |
321 | - $this->li_of = [ $limit, $offset ]; |
|
321 | + $this->li_of = [$limit, $offset]; |
|
322 | 322 | return $this; |
323 | 323 | } |
324 | 324 | /** |
@@ -335,22 +335,22 @@ discard block |
||
335 | 335 | $relations = $this->withr; |
336 | 336 | foreach ($this->definition->getRelations() as $k => $v) { |
337 | 337 | foreach ($this->where as $vv) { |
338 | - if (strpos($vv[0], $k . '.') !== false) { |
|
338 | + if (strpos($vv[0], $k.'.') !== false) { |
|
339 | 339 | $relations[] = $k; |
340 | 340 | } |
341 | 341 | } |
342 | - if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) { |
|
342 | + if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) { |
|
343 | 343 | $relations[] = $k; |
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | foreach ($this->joins as $k => $v) { |
348 | - $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
348 | + $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
349 | 349 | $tmp = []; |
350 | 350 | foreach ($v->keymap as $kk => $vv) { |
351 | 351 | $tmp[] = $kk.' = '.$vv; |
352 | 352 | } |
353 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
353 | + $sql .= implode(' AND ', $tmp).' '; |
|
354 | 354 | } |
355 | 355 | foreach (array_unique($relations) as $k) { |
356 | 356 | $v = $this->definition->getRelation($k); |
@@ -360,13 +360,13 @@ discard block |
||
360 | 360 | foreach ($v->keymap as $kk => $vv) { |
361 | 361 | $tmp[] = $table.'.'.$kk.' = '.$k.'_pivot.'.$vv.' '; |
362 | 362 | } |
363 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
363 | + $sql .= implode(' AND ', $tmp).' '; |
|
364 | 364 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON '; |
365 | 365 | $tmp = []; |
366 | 366 | foreach ($v->pivot_keymap as $kk => $vv) { |
367 | 367 | $tmp[] = $k.'.'.$vv.' = '.$k.'_pivot.'.$kk.' '; |
368 | 368 | } |
369 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
369 | + $sql .= implode(' AND ', $tmp).' '; |
|
370 | 370 | } else { |
371 | 371 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON '; |
372 | 372 | $tmp = []; |
@@ -374,30 +374,30 @@ discard block |
||
374 | 374 | $tmp[] = $table.'.'.$kk.' = '.$k.'.'.$vv.' '; |
375 | 375 | } |
376 | 376 | if ($v->sql) { |
377 | - $tmp[] = $v->sql . ' '; |
|
377 | + $tmp[] = $v->sql.' '; |
|
378 | 378 | $par = array_merge($par, $v->par ?? []); |
379 | 379 | } |
380 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
380 | + $sql .= implode(' AND ', $tmp).' '; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | if (count($this->where)) { |
384 | 384 | $sql .= 'WHERE '; |
385 | 385 | $tmp = []; |
386 | 386 | foreach ($this->where as $v) { |
387 | - $tmp[] = '(' . $v[0] . ')'; |
|
387 | + $tmp[] = '('.$v[0].')'; |
|
388 | 388 | $par = array_merge($par, $v[1]); |
389 | 389 | } |
390 | 390 | $sql .= implode(' AND ', $tmp).' '; |
391 | 391 | } |
392 | 392 | if (count($this->group)) { |
393 | - $sql .= 'GROUP BY ' . $this->group[0] . ' '; |
|
393 | + $sql .= 'GROUP BY '.$this->group[0].' '; |
|
394 | 394 | $par = array_merge($par, $this->group[1]); |
395 | 395 | } |
396 | 396 | if (count($this->having)) { |
397 | 397 | $sql .= 'HAVING '; |
398 | 398 | $tmp = []; |
399 | 399 | foreach ($this->having as $v) { |
400 | - $tmp[] = '(' . $v[0] . ')'; |
|
400 | + $tmp[] = '('.$v[0].')'; |
|
401 | 401 | $par = array_merge($par, $v[1]); |
402 | 402 | } |
403 | 403 | $sql .= implode(' AND ', $tmp).' '; |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | throw new DatabaseException('Invalid foreign table name'); |
429 | 429 | } |
430 | 430 | foreach ($cols as $col) { |
431 | - $fields[] = $table . '.' . $col; |
|
431 | + $fields[] = $table.'.'.$col; |
|
432 | 432 | } |
433 | 433 | unset($fields[$k]); |
434 | 434 | } |
@@ -468,37 +468,37 @@ discard block |
||
468 | 468 | $relations = $this->withr; |
469 | 469 | foreach ($this->definition->getRelations() as $k => $v) { |
470 | 470 | foreach ($this->fields as $field) { |
471 | - if (strpos($field, $k . '.') === 0) { |
|
471 | + if (strpos($field, $k.'.') === 0) { |
|
472 | 472 | $relations[] = $k; |
473 | 473 | } |
474 | 474 | } |
475 | 475 | foreach ($this->where as $v) { |
476 | - if (strpos($v[0], $k . '.') !== false) { |
|
476 | + if (strpos($v[0], $k.'.') !== false) { |
|
477 | 477 | $relations[] = $k; |
478 | 478 | } |
479 | 479 | } |
480 | - if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) { |
|
480 | + if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) { |
|
481 | 481 | $relations[] = $k; |
482 | 482 | } |
483 | 483 | } |
484 | 484 | $select = []; |
485 | 485 | foreach ($this->fields as $k => $field) { |
486 | - $select[] = $field . (!is_numeric($k) ? ' ' . $k : ''); |
|
486 | + $select[] = $field.(!is_numeric($k) ? ' '.$k : ''); |
|
487 | 487 | } |
488 | 488 | foreach ($this->withr as $relation) { |
489 | 489 | foreach ($this->definition->getRelation($relation)->table->getColumns() as $column) { |
490 | - $select[] = $relation . '.' . $column . ' ' . $relation . '___' . $column; |
|
490 | + $select[] = $relation.'.'.$column.' '.$relation.'___'.$column; |
|
491 | 491 | } |
492 | 492 | } |
493 | 493 | $sql = 'SELECT '.implode(', ', $select).' FROM '.$table.' '; |
494 | 494 | $par = []; |
495 | 495 | foreach ($this->joins as $k => $v) { |
496 | - $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
496 | + $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON '; |
|
497 | 497 | $tmp = []; |
498 | 498 | foreach ($v->keymap as $kk => $vv) { |
499 | 499 | $tmp[] = $kk.' = '.$vv; |
500 | 500 | } |
501 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
501 | + $sql .= implode(' AND ', $tmp).' '; |
|
502 | 502 | } |
503 | 503 | foreach (array_unique($relations) as $relation) { |
504 | 504 | $v = $this->definition->getRelation($relation); |
@@ -508,13 +508,13 @@ discard block |
||
508 | 508 | foreach ($v->keymap as $kk => $vv) { |
509 | 509 | $tmp[] = $table.'.'.$kk.' = '.$relation.'_pivot.'.$vv.' '; |
510 | 510 | } |
511 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
511 | + $sql .= implode(' AND ', $tmp).' '; |
|
512 | 512 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON '; |
513 | 513 | $tmp = []; |
514 | 514 | foreach ($v->pivot_keymap as $kk => $vv) { |
515 | 515 | $tmp[] = $relation.'.'.$vv.' = '.$relation.'_pivot.'.$kk.' '; |
516 | 516 | } |
517 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
517 | + $sql .= implode(' AND ', $tmp).' '; |
|
518 | 518 | } else { |
519 | 519 | $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON '; |
520 | 520 | $tmp = []; |
@@ -522,30 +522,30 @@ discard block |
||
522 | 522 | $tmp[] = $table.'.'.$kk.' = '.$relation.'.'.$vv.' '; |
523 | 523 | } |
524 | 524 | if ($v->sql) { |
525 | - $tmp[] = $v->sql . ' '; |
|
525 | + $tmp[] = $v->sql.' '; |
|
526 | 526 | $par = array_merge($par, $v->par ?? []); |
527 | 527 | } |
528 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
528 | + $sql .= implode(' AND ', $tmp).' '; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 | if (count($this->where)) { |
532 | 532 | $sql .= 'WHERE '; |
533 | 533 | $tmp = []; |
534 | 534 | foreach ($this->where as $v) { |
535 | - $tmp[] = '(' . $v[0] . ')'; |
|
535 | + $tmp[] = '('.$v[0].')'; |
|
536 | 536 | $par = array_merge($par, $v[1]); |
537 | 537 | } |
538 | 538 | $sql .= implode(' AND ', $tmp).' '; |
539 | 539 | } |
540 | 540 | if (count($this->group)) { |
541 | - $sql .= 'GROUP BY ' . $this->group[0] . ' '; |
|
541 | + $sql .= 'GROUP BY '.$this->group[0].' '; |
|
542 | 542 | $par = array_merge($par, $this->group[1]); |
543 | 543 | } |
544 | 544 | if (count($this->having)) { |
545 | 545 | $sql .= 'HAVING '; |
546 | 546 | $tmp = []; |
547 | 547 | foreach ($this->having as $v) { |
548 | - $tmp[] = '(' . $v[0] . ')'; |
|
548 | + $tmp[] = '('.$v[0].')'; |
|
549 | 549 | $par = array_merge($par, $v[1]); |
550 | 550 | } |
551 | 551 | $sql .= implode(' AND ', $tmp).' '; |
@@ -554,36 +554,36 @@ discard block |
||
554 | 554 | // $sql .= 'GROUP BY '.$table.'.'.implode(', '.$table.'.', $primary).' '; |
555 | 555 | //} |
556 | 556 | if (count($this->order)) { |
557 | - $sql .= 'ORDER BY ' . $this->order[0] . ' '; |
|
557 | + $sql .= 'ORDER BY '.$this->order[0].' '; |
|
558 | 558 | $par = array_merge($par, $this->order[1]); |
559 | 559 | } |
560 | 560 | $porder = []; |
561 | 561 | foreach ($primary as $field) { |
562 | 562 | $porder[] = $this->getColumn($field)['name']; |
563 | 563 | } |
564 | - $sql .= (count($this->order) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' '; |
|
564 | + $sql .= (count($this->order) ? ', ' : 'ORDER BY ').implode(', ', $porder).' '; |
|
565 | 565 | |
566 | 566 | if ($this->li_of[0]) { |
567 | 567 | if ($this->db->driver() === 'oracle') { |
568 | - if ((int)($this->db->settings()->options['version'] ?? 0) >= 12) { |
|
569 | - $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY'; |
|
568 | + if ((int) ($this->db->settings()->options['version'] ?? 0) >= 12) { |
|
569 | + $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY'; |
|
570 | 570 | } else { |
571 | - $f = array_map(function ($v) { |
|
571 | + $f = array_map(function($v) { |
|
572 | 572 | $v = explode(' ', trim($v), 2); |
573 | 573 | if (count($v) === 2) { return $v[1]; } |
574 | 574 | $v = explode('.', $v[0], 2); |
575 | 575 | return count($v) === 2 ? $v[1] : $v[0]; |
576 | 576 | }, $select); |
577 | - $sql = "SELECT " . implode(', ', $f) . " |
|
577 | + $sql = "SELECT ".implode(', ', $f)." |
|
578 | 578 | FROM ( |
579 | 579 | SELECT tbl__.*, rownum rnum__ FROM ( |
580 | - " . $sql . " |
|
580 | + " . $sql." |
|
581 | 581 | ) tbl__ |
582 | - WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . " |
|
582 | + WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])." |
|
583 | 583 | ) WHERE rnum__ > " . $this->li_of[1]; |
584 | 584 | } |
585 | 585 | } else { |
586 | - $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1]; |
|
586 | + $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1]; |
|
587 | 587 | } |
588 | 588 | } |
589 | 589 | // echo $sql; die(); |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | $this->definition->getPrimaryKey(), |
593 | 593 | array_combine( |
594 | 594 | $this->withr, |
595 | - array_map(function ($relation) { |
|
595 | + array_map(function($relation) { |
|
596 | 596 | return $this->definition->getRelation($relation); |
597 | 597 | }, $this->withr) |
598 | 598 | ) |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | $ret[$k] = str_repeat(' ', 255); |
640 | 640 | $par[] = &$ret[$k]; |
641 | 641 | } |
642 | - $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?')); |
|
642 | + $sql .= ' RETURNING '.implode(',', $primary).' INTO '.implode(',', array_fill(0, count($primary), '?')); |
|
643 | 643 | $this->db->query($sql, $par); |
644 | 644 | return $ret; |
645 | 645 | } else { |
@@ -671,7 +671,7 @@ discard block |
||
671 | 671 | } |
672 | 672 | $sql = 'UPDATE '.$table.' SET '; |
673 | 673 | $par = []; |
674 | - $sql .= implode(', ', array_map(function ($v) { return $v . ' = ?'; }, array_keys($update))) . ' '; |
|
674 | + $sql .= implode(', ', array_map(function($v) { return $v.' = ?'; }, array_keys($update))).' '; |
|
675 | 675 | $par = array_merge($par, array_values($update)); |
676 | 676 | if (count($this->where)) { |
677 | 677 | $sql .= 'WHERE '; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | $tmp[] = $v[0]; |
681 | 681 | $par = array_merge($par, $v[1]); |
682 | 682 | } |
683 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
683 | + $sql .= implode(' AND ', $tmp).' '; |
|
684 | 684 | } |
685 | 685 | if (count($this->order)) { |
686 | 686 | $sql .= $this->order[0]; |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | $tmp[] = $v[0]; |
705 | 705 | $par = array_merge($par, $v[1]); |
706 | 706 | } |
707 | - $sql .= implode(' AND ', $tmp) . ' '; |
|
707 | + $sql .= implode(' AND ', $tmp).' '; |
|
708 | 708 | } |
709 | 709 | if (count($this->order)) { |
710 | 710 | $sql .= $this->order[0]; |