Completed
Push — master ( ce4a45...4f05e7 )
by Ivan
04:08
created
src/driver/ibase/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
         $this->connect();
53 53
         $statement = \ibase_prepare($this->transaction !== null ? $this->transaction : $this->lnk, $sql);
54 54
         if ($statement === false) {
55
-            throw new DBException('Prepare error: ' . \ibase_errmsg());
55
+            throw new DBException('Prepare error: '.\ibase_errmsg());
56 56
         }
57 57
         return new Statement(
58 58
             $statement,
Please login to merge, or discard this patch.
src/driver/pdo/Statement.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,28 +24,28 @@
 block discarded – undo
24 24
         foreach ($data as $i => $v) {
25 25
             switch (gettype($v)) {
26 26
                 case 'boolean':
27
-                    $this->statement->bindValue($i+1, $v, \PDO::PARAM_BOOL);
27
+                    $this->statement->bindValue($i + 1, $v, \PDO::PARAM_BOOL);
28 28
                     break;
29 29
                 case 'integer':
30
-                    $this->statement->bindValue($i+1, $v, \PDO::PARAM_INT);
30
+                    $this->statement->bindValue($i + 1, $v, \PDO::PARAM_INT);
31 31
                     break;
32 32
                 case 'NULL':
33
-                    $this->statement->bindValue($i+1, $v, \PDO::PARAM_NULL);
33
+                    $this->statement->bindValue($i + 1, $v, \PDO::PARAM_NULL);
34 34
                     break;
35 35
                 case 'double':
36
-                    $this->statement->bindValue($i+1, $v);
36
+                    $this->statement->bindValue($i + 1, $v);
37 37
                     break;
38 38
                 default:
39 39
                     // keep in mind oracle needs a transaction when inserting LOBs, aside from the specific syntax:
40 40
                     // INSERT INTO table (column, lobcolumn) VALUES (?, ?, EMPTY_BLOB()) RETURNING lobcolumn INTO ?
41 41
                     if (is_resource($v) && get_resource_type($v) === 'stream') {
42
-                        $this->statement->bindParam($i+1, $v, \PDO::PARAM_LOB);
42
+                        $this->statement->bindParam($i + 1, $v, \PDO::PARAM_LOB);
43 43
                         continue;
44 44
                     }
45 45
                     if (!is_string($data[$i])) {
46 46
                         $data[$i] = serialize($data[$i]);
47 47
                     }
48
-                    $this->statement->bindValue($i+1, $v);
48
+                    $this->statement->bindValue($i + 1, $v);
49 49
                     break;
50 50
             }
51 51
         }
Please login to merge, or discard this patch.
src/driver/pdo/Result.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
     }
56 56
     public function next()
57 57
     {
58
-        $this->fetched ++;
58
+        $this->fetched++;
59 59
         $this->last = $this->statement->fetch(\PDO::FETCH_ASSOC);
60 60
     }
61 61
     public function valid()
Please login to merge, or discard this patch.
src/driver/pdo/Driver.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
                     isset($this->connection['opts']) ? $this->connection['opts'] : []
45 45
                 );
46 46
             } catch (\PDOException $e) {
47
-                throw new DBException('Connect error: ' . $e->getMessage());
47
+                throw new DBException('Connect error: '.$e->getMessage());
48 48
             }
49 49
         }
50 50
     }
Please login to merge, or discard this patch.
src/schema/TableColumn.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/schema/Table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,
Please login to merge, or discard this patch.
src/schema/TableQueryIterator.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,27 +65,27 @@  discard block
 block discarded – undo
65 65
                 $fields = [];
66 66
                 $exists = false;
67 67
                 foreach ($relation->table->getColumns() as $column) {
68
-                    $fields[$column] = $row[$name . static::SEP . $column];
69
-                    if (!$exists && $row[$name . static::SEP . $column] !== null) {
68
+                    $fields[$column] = $row[$name.static::SEP.$column];
69
+                    if (!$exists && $row[$name.static::SEP.$column] !== null) {
70 70
                         $exists = true;
71 71
                     }
72
-                    $remove[] = $name . static::SEP . $column;
72
+                    $remove[] = $name.static::SEP.$column;
73 73
                 }
74 74
                 $temp  = &$result;
75 75
                 $parts = explode(static::SEP, $name);
76 76
                 $name  = array_pop($parts);
77 77
                 $full  = '';
78 78
                 foreach ($parts as $item) {
79
-                    $full = $full ? $full . static::SEP . $item : $item;
79
+                    $full = $full ? $full.static::SEP.$item : $item;
80 80
                     $temp = &$temp[$item];
81 81
                     $rpk = [];
82 82
                     foreach ($this->relations[$full][0]->table->getPrimaryKey() as $pkey) {
83
-                        $rpk[$field] = $row[$full . static::SEP . $field];
83
+                        $rpk[$field] = $row[$full.static::SEP.$field];
84 84
                     }
85 85
                     $temp = &$temp[json_encode($rpk)];
86 86
                 }
87 87
                 if (!isset($temp[$name])) {
88
-                    $temp[$name] = $relation->many ? [ '___clean' => true ] : null;
88
+                    $temp[$name] = $relation->many ? ['___clean' => true] : null;
89 89
                 }
90 90
                 $temp = &$temp[$name];
91 91
                 if ($exists) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 return;
145 145
             }
146 146
         }
147
-        $this->fetched ++;
147
+        $this->fetched++;
148 148
         while ($this->result->valid()) {
149 149
             $row = $this->result->current();
150 150
             $pk = [];
Please login to merge, or discard this patch.
src/schema/TableQuery.php 1 patch
Spacing   +77 added lines, -80 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     /**
44 44
      * @var int[]
45 45
      */
46
-    protected $li_of = [0,0];
46
+    protected $li_of = [0, 0];
47 47
     /**
48 48
      * @var array
49 49
      */
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
     public function __construct(DBInterface $db, $table)
66 66
     {
67 67
         $this->db = $db;
68
-        $this->definition = $table instanceof Table ? $table : $this->db->definition((string)$table);
68
+        $this->definition = $table instanceof Table ? $table : $this->db->definition((string) $table);
69 69
         $this->columns($this->definition->getColumns());
70 70
     }
71 71
     public function __clone()
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $column = explode('.', $column);
87 87
         if (count($column) === 1) {
88
-            $column = [ $this->definition->getName(), $column[0] ];
88
+            $column = [$this->definition->getName(), $column[0]];
89 89
             $col = $this->definition->getColumn($column[1]);
90 90
         } elseif (count($column) === 2) {
91 91
             if ($column[0] === $this->definition->getName()) {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                         throw new DBException('Invalid column name in related table');
106 106
                     }
107 107
                 } else {
108
-                    throw new DBException('Invalid foreign table name: ' . implode(',', $column));
108
+                    throw new DBException('Invalid foreign table name: '.implode(',', $column));
109 109
                 }
110 110
             }
111 111
         } else {
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
             $table = $this->definition;
115 115
             $table = array_reduce(
116 116
                 $column,
117
-                function ($carry, $item) use (&$table) {
117
+                function($carry, $item) use (&$table) {
118 118
                     $table = $table->getRelation($item)->table;
119 119
                     return $table;
120 120
                 }
121 121
             );
122 122
             $col = $table->getColumn($name);
123
-            $column = [ implode(static::SEP, $column), $name ];
123
+            $column = [implode(static::SEP, $column), $name];
124 124
         }
125
-        return [ 'name' => implode('.', $column), 'data' => $col ];
125
+        return ['name' => implode('.', $column), 'data' => $col];
126 126
     }
127 127
     protected function normalizeValue(TableColumn $col, $value)
128 128
     {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                 }
162 162
                 return $value;
163 163
             case 'int':
164
-                return (int)$value;
164
+                return (int) $value;
165 165
             default:
166 166
                 return $value;
167 167
         }
@@ -178,18 +178,16 @@  discard block
 block discarded – undo
178 178
         list($name, $column) = array_values($this->getColumn($column));
179 179
         if (is_null($value)) {
180 180
             return $negate ?
181
-                $this->where($name . ' IS NOT NULL') :
182
-                $this->where($name . ' IS NULL');
181
+                $this->where($name.' IS NOT NULL') : $this->where($name.' IS NULL');
183 182
         }
184 183
         if (!is_array($value)) {
185 184
             return $negate ?
186 185
                 $this->where(
187
-                    $name . ' <> ?',
188
-                    [ $this->normalizeValue($column, $value) ]
189
-                ) :
190
-                $this->where(
191
-                    $name . ' = ?',
192
-                    [ $this->normalizeValue($column, $value) ]
186
+                    $name.' <> ?',
187
+                    [$this->normalizeValue($column, $value)]
188
+                ) : $this->where(
189
+                    $name.' = ?',
190
+                    [$this->normalizeValue($column, $value)]
193 191
                 );
194 192
         }
195 193
         if (isset($value['beg']) && isset($value['end'])) {
@@ -200,8 +198,7 @@  discard block
 block discarded – undo
200 198
                         $this->normalizeValue($column, $value['beg']),
201 199
                         $this->normalizeValue($column, $value['end'])
202 200
                     ]
203
-                ) :
204
-                $this->where(
201
+                ) : $this->where(
205 202
                     $name.' BETWEEN ? AND ?',
206 203
                     [
207 204
                         $this->normalizeValue($column, $value['beg']),
@@ -211,12 +208,12 @@  discard block
 block discarded – undo
211 208
         }
212 209
         return $negate ?
213 210
             $this->where(
214
-                $name . ' NOT IN (??)',
215
-                [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ]
211
+                $name.' NOT IN (??)',
212
+                [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)]
216 213
             ) :
217 214
             $this->where(
218
-                $name . ' IN (??)',
219
-                [ array_map(function ($v) use ($column) { return $this->normalizeValue($column, $v); }, $value) ]
215
+                $name.' IN (??)',
216
+                [array_map(function($v) use ($column) { return $this->normalizeValue($column, $v); }, $value)]
220 217
             );
221 218
     }
222 219
     /**
@@ -227,7 +224,7 @@  discard block
 block discarded – undo
227 224
      */
228 225
     public function sort(string $column, bool $desc = false) : TableQuery
229 226
     {
230
-        return $this->order($this->getColumn($column)['name'] . ' ' . ($desc ? 'DESC' : 'ASC'));
227
+        return $this->order($this->getColumn($column)['name'].' '.($desc ? 'DESC' : 'ASC'));
231 228
     }
232 229
     /**
233 230
      * Group by a column (or columns)
@@ -237,7 +234,7 @@  discard block
 block discarded – undo
237 234
     public function group($column) : TableQuery
238 235
     {
239 236
         if (!is_array($column)) {
240
-            $column = [ $column ];
237
+            $column = [$column];
241 238
         }
242 239
         foreach ($column as $k => $v) {
243 240
             $column[$k] = $this->getColumn($v)['name'];
@@ -278,7 +275,7 @@  discard block
 block discarded – undo
278 275
         $this->withr = [];
279 276
         $this->order = [];
280 277
         $this->having = [];
281
-        $this->li_of = [0,0];
278
+        $this->li_of = [0, 0];
282 279
         $this->qiterator = null;
283 280
         return $this;
284 281
     }
@@ -291,7 +288,7 @@  discard block
 block discarded – undo
291 288
     public function groupBy(string $sql, array $params = []) : TableQuery
292 289
     {
293 290
         $this->qiterator = null;
294
-        $this->group = [ $sql, $params ];
291
+        $this->group = [$sql, $params];
295 292
         return $this;
296 293
     }
297 294
     /**
@@ -304,7 +301,7 @@  discard block
 block discarded – undo
304 301
      */
305 302
     public function join($table, array $fields, string $name = null, bool $multiple = true)
306 303
     {
307
-        $table = $table instanceof Table ? $table : $this->db->definition((string)$table);
304
+        $table = $table instanceof Table ? $table : $this->db->definition((string) $table);
308 305
         $name = $name ?? $table->getName();
309 306
         if (isset($this->joins[$name]) || $this->definition->hasRelation($name)) {
310 307
             throw new DBException('Alias / table name already in use');
@@ -313,7 +310,7 @@  discard block
 block discarded – undo
313 310
         foreach ($fields as $k => $v) {
314 311
             $k = explode('.', $k, 2);
315 312
             $k = count($k) == 2 ? $k[1] : $k[0];
316
-            $this->joins[$name]->keymap[$this->getColumn($name . '.' . $k)['name']] = $this->getColumn($v)['name'];
313
+            $this->joins[$name]->keymap[$this->getColumn($name.'.'.$k)['name']] = $this->getColumn($v)['name'];
317 314
         }
318 315
         return $this;
319 316
     }
@@ -326,7 +323,7 @@  discard block
 block discarded – undo
326 323
     public function where(string $sql, array $params = []) : TableQuery
327 324
     {
328 325
         $this->qiterator = null;
329
-        $this->where[] = [ $sql, $params ];
326
+        $this->where[] = [$sql, $params];
330 327
         return $this;
331 328
     }
332 329
     /**
@@ -338,7 +335,7 @@  discard block
 block discarded – undo
338 335
     public function having(string $sql, array $params = []) : TableQuery
339 336
     {
340 337
         $this->qiterator = null;
341
-        $this->having[] = [ $sql, $params ];
338
+        $this->having[] = [$sql, $params];
342 339
         return $this;
343 340
     }
344 341
     /**
@@ -350,7 +347,7 @@  discard block
 block discarded – undo
350 347
     public function order(string $sql, array $params = []) : TableQuery
351 348
     {
352 349
         $this->qiterator = null;
353
-        $this->order = [ $sql, $params ];
350
+        $this->order = [$sql, $params];
354 351
         return $this;
355 352
     }
356 353
     /**
@@ -362,7 +359,7 @@  discard block
 block discarded – undo
362 359
     public function limit(int $limit, int $offset = 0) : TableQuery
363 360
     {
364 361
         $this->qiterator = null;
365
-        $this->li_of = [ $limit, $offset ];
362
+        $this->li_of = [$limit, $offset];
366 363
         return $this;
367 364
     }
368 365
     /**
@@ -379,22 +376,22 @@  discard block
 block discarded – undo
379 376
         $relations = $this->withr;
380 377
         foreach ($this->definition->getRelations() as $k => $v) {
381 378
             foreach ($this->where as $vv) {
382
-                if (strpos($vv[0], $k . '.') !== false) {
383
-                    $relations[$k] = [ $v, $table ];
379
+                if (strpos($vv[0], $k.'.') !== false) {
380
+                    $relations[$k] = [$v, $table];
384 381
                 }
385 382
             }
386
-            if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) {
387
-                $relations[$k] = [ $v, $table ];
383
+            if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) {
384
+                $relations[$k] = [$v, $table];
388 385
             }
389 386
         }
390 387
 
391 388
         foreach ($this->joins as $k => $v) {
392
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON ';
389
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON ';
393 390
             $tmp = [];
394 391
             foreach ($v->keymap as $kk => $vv) {
395 392
                 $tmp[] = $kk.' = '.$vv;
396 393
             }
397
-            $sql .= implode(' AND ', $tmp) . ' ';
394
+            $sql .= implode(' AND ', $tmp).' ';
398 395
         }
399 396
         foreach ($relations as $k => $v) {
400 397
             $table = $v[1];
@@ -405,13 +402,13 @@  discard block
 block discarded – undo
405 402
                 foreach ($v->keymap as $kk => $vv) {
406 403
                     $tmp[] = $table.'.'.$kk.' = '.$k.'_pivot.'.$vv.' ';
407 404
                 }
408
-                $sql .= implode(' AND ', $tmp) . ' ';
405
+                $sql .= implode(' AND ', $tmp).' ';
409 406
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON ';
410 407
                 $tmp = [];
411 408
                 foreach ($v->pivot_keymap as $kk => $vv) {
412 409
                     $tmp[] = $k.'.'.$vv.' = '.$k.'_pivot.'.$kk.' ';
413 410
                 }
414
-                $sql .= implode(' AND ', $tmp) . ' ';
411
+                $sql .= implode(' AND ', $tmp).' ';
415 412
             } else {
416 413
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$k.' ON ';
417 414
                 $tmp = [];
@@ -419,30 +416,30 @@  discard block
 block discarded – undo
419 416
                     $tmp[] = $table.'.'.$kk.' = '.$k.'.'.$vv.' ';
420 417
                 }
421 418
                 if ($v->sql) {
422
-                    $tmp[] = $v->sql . ' ';
419
+                    $tmp[] = $v->sql.' ';
423 420
                     $par = array_merge($par, $v->par ?? []);
424 421
                 }
425
-                $sql .= implode(' AND ', $tmp) . ' ';
422
+                $sql .= implode(' AND ', $tmp).' ';
426 423
             }
427 424
         }
428 425
         if (count($this->where)) {
429 426
             $sql .= 'WHERE ';
430 427
             $tmp = [];
431 428
             foreach ($this->where as $v) {
432
-                $tmp[] = '(' . $v[0] . ')';
429
+                $tmp[] = '('.$v[0].')';
433 430
                 $par = array_merge($par, $v[1]);
434 431
             }
435 432
             $sql .= implode(' AND ', $tmp).' ';
436 433
         }
437 434
         if (count($this->group)) {
438
-            $sql .= 'GROUP BY ' . $this->group[0] . ' ';
435
+            $sql .= 'GROUP BY '.$this->group[0].' ';
439 436
             $par = array_merge($par, $this->group[1]);
440 437
         }
441 438
         if (count($this->having)) {
442 439
             $sql .= 'HAVING ';
443 440
             $tmp = [];
444 441
             foreach ($this->having as $v) {
445
-                $tmp[] = '(' . $v[0] . ')';
442
+                $tmp[] = '('.$v[0].')';
446 443
                 $par = array_merge($par, $v[1]);
447 444
             }
448 445
             $sql .= implode(' AND ', $tmp).' ';
@@ -478,7 +475,7 @@  discard block
 block discarded – undo
478 475
                     $this->with(implode('.', $temp));
479 476
                     $table = array_reduce(
480 477
                         $temp,
481
-                        function ($carry, $item) use (&$table) {
478
+                        function($carry, $item) use (&$table) {
482 479
                             return $table->getRelation($item)->table;
483 480
                         }
484 481
                     );
@@ -487,7 +484,7 @@  discard block
 block discarded – undo
487 484
                 }
488 485
                 unset($fields[$k]);
489 486
                 foreach ($cols as $col) {
490
-                    $fields[] = $table . '.' . $col;
487
+                    $fields[] = $table.'.'.$col;
491 488
                 }
492 489
             }
493 490
         }
@@ -526,37 +523,37 @@  discard block
 block discarded – undo
526 523
         $relations = $this->withr;
527 524
         foreach ($this->definition->getRelations() as $k => $relation) {
528 525
             foreach ($this->fields as $field) {
529
-                if (strpos($field, $k . '.') === 0) {
530
-                    $relations[$k] = [ $relation, $table ];
526
+                if (strpos($field, $k.'.') === 0) {
527
+                    $relations[$k] = [$relation, $table];
531 528
                 }
532 529
             }
533 530
             foreach ($this->where as $v) {
534
-                if (strpos($v[0], $k . '.') !== false) {
535
-                    $relations[$k] = [ $relation, $table ];
531
+                if (strpos($v[0], $k.'.') !== false) {
532
+                    $relations[$k] = [$relation, $table];
536 533
                 }
537 534
             }
538
-            if (isset($this->order[0]) && strpos($this->order[0], $k . '.') !== false) {
539
-                $relations[$k] = [ $relation, $table ];
535
+            if (isset($this->order[0]) && strpos($this->order[0], $k.'.') !== false) {
536
+                $relations[$k] = [$relation, $table];
540 537
             }
541 538
         }
542 539
         $select = [];
543 540
         foreach ($this->fields as $k => $field) {
544
-            $select[] = $field . (!is_numeric($k) ? ' ' . $k : '');
541
+            $select[] = $field.(!is_numeric($k) ? ' '.$k : '');
545 542
         }
546 543
         foreach ($this->withr as $name => $relation) {
547 544
             foreach ($relation[0]->table->getColumns() as $column) {
548
-                $select[] = $name . '.' . $column . ' ' . $name . static::SEP . $column;
545
+                $select[] = $name.'.'.$column.' '.$name.static::SEP.$column;
549 546
             }
550 547
         }
551 548
         $sql = 'SELECT '.implode(', ', $select).' FROM '.$table.' ';
552 549
         $par = [];
553 550
         foreach ($this->joins as $k => $v) {
554
-            $sql .= ($v->many ? 'LEFT ' : '' ) . 'JOIN '.$v->table->getName().' '.$k.' ON ';
551
+            $sql .= ($v->many ? 'LEFT ' : '').'JOIN '.$v->table->getName().' '.$k.' ON ';
555 552
             $tmp = [];
556 553
             foreach ($v->keymap as $kk => $vv) {
557 554
                 $tmp[] = $kk.' = '.$vv;
558 555
             }
559
-            $sql .= implode(' AND ', $tmp) . ' ';
556
+            $sql .= implode(' AND ', $tmp).' ';
560 557
         }
561 558
         foreach ($relations as $relation => $v) {
562 559
             $table = $v[1];
@@ -567,13 +564,13 @@  discard block
 block discarded – undo
567 564
                 foreach ($v->keymap as $kk => $vv) {
568 565
                     $tmp[] = $table.'.'.$kk.' = '.$relation.'_pivot.'.$vv.' ';
569 566
                 }
570
-                $sql .= implode(' AND ', $tmp) . ' ';
567
+                $sql .= implode(' AND ', $tmp).' ';
571 568
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON ';
572 569
                 $tmp = [];
573 570
                 foreach ($v->pivot_keymap as $kk => $vv) {
574 571
                     $tmp[] = $relation.'.'.$vv.' = '.$relation.'_pivot.'.$kk.' ';
575 572
                 }
576
-                $sql .= implode(' AND ', $tmp) . ' ';
573
+                $sql .= implode(' AND ', $tmp).' ';
577 574
             } else {
578 575
                 $sql .= 'LEFT JOIN '.$v->table->getName().' '.$relation.' ON ';
579 576
                 $tmp = [];
@@ -581,30 +578,30 @@  discard block
 block discarded – undo
581 578
                     $tmp[] = $table.'.'.$kk.' = '.$relation.'.'.$vv.' ';
582 579
                 }
583 580
                 if ($v->sql) {
584
-                    $tmp[] = $v->sql . ' ';
581
+                    $tmp[] = $v->sql.' ';
585 582
                     $par = array_merge($par, $v->par ?? []);
586 583
                 }
587
-                $sql .= implode(' AND ', $tmp) . ' ';
584
+                $sql .= implode(' AND ', $tmp).' ';
588 585
             }
589 586
         }
590 587
         if (count($this->where)) {
591 588
             $sql .= 'WHERE ';
592 589
             $tmp = [];
593 590
             foreach ($this->where as $v) {
594
-                $tmp[] = '(' . $v[0] . ')';
591
+                $tmp[] = '('.$v[0].')';
595 592
                 $par = array_merge($par, $v[1]);
596 593
             }
597 594
             $sql .= implode(' AND ', $tmp).' ';
598 595
         }
599 596
         if (count($this->group)) {
600
-            $sql .= 'GROUP BY ' . $this->group[0] . ' ';
597
+            $sql .= 'GROUP BY '.$this->group[0].' ';
601 598
             $par = array_merge($par, $this->group[1]);
602 599
         }
603 600
         if (count($this->having)) {
604 601
             $sql .= 'HAVING ';
605 602
             $tmp = [];
606 603
             foreach ($this->having as $v) {
607
-                $tmp[] = '(' . $v[0] . ')';
604
+                $tmp[] = '('.$v[0].')';
608 605
                 $par = array_merge($par, $v[1]);
609 606
             }
610 607
             $sql .= implode(' AND ', $tmp).' ';
@@ -613,36 +610,36 @@  discard block
 block discarded – undo
613 610
         //    $sql .= 'GROUP BY '.$table.'.'.implode(', '.$table.'.', $primary).' ';
614 611
         //}
615 612
         if (count($this->order)) {
616
-            $sql .= 'ORDER BY ' . $this->order[0] . ' ';
613
+            $sql .= 'ORDER BY '.$this->order[0].' ';
617 614
             $par = array_merge($par, $this->order[1]);
618 615
         }
619 616
         $porder = [];
620 617
         foreach ($primary as $field) {
621 618
             $porder[] = $this->getColumn($field)['name'];
622 619
         }
623
-        $sql .= (count($this->order) ? ', ' : 'ORDER BY ') . implode(', ', $porder) . ' ';
620
+        $sql .= (count($this->order) ? ', ' : 'ORDER BY ').implode(', ', $porder).' ';
624 621
 
625 622
         if ($this->li_of[0]) {
626 623
             if ($this->db->driver() === 'oracle') {
627
-                if ((int)($this->db->settings()->options['version'] ?? 0) >= 12) {
628
-                    $sql .= 'OFFSET ' . $this->li_of[1] . ' ROWS FETCH NEXT ' . $this->li_of[0] . ' ROWS ONLY';
624
+                if ((int) ($this->db->settings()->options['version'] ?? 0) >= 12) {
625
+                    $sql .= 'OFFSET '.$this->li_of[1].' ROWS FETCH NEXT '.$this->li_of[0].' ROWS ONLY';
629 626
                 } else {
630
-                    $f = array_map(function ($v) {
627
+                    $f = array_map(function($v) {
631 628
                         $v = explode(' ', trim($v), 2);
632 629
                         if (count($v) === 2) { return $v[1]; }
633 630
                         $v = explode('.', $v[0], 2);
634 631
                         return count($v) === 2 ? $v[1] : $v[0];
635 632
                     }, $select);
636
-                    $sql = "SELECT " . implode(', ', $f) . " 
633
+                    $sql = "SELECT ".implode(', ', $f)." 
637 634
                             FROM (
638 635
                                 SELECT tbl__.*, rownum rnum__ FROM (
639
-                                    " . $sql . "
636
+                                    " . $sql."
640 637
                                 ) tbl__ 
641
-                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1]) . "
638
+                                WHERE rownum <= " . ($this->li_of[0] + $this->li_of[1])."
642 639
                             ) WHERE rnum__ > " . $this->li_of[1];
643 640
                 }
644 641
             } else {
645
-                $sql .= 'LIMIT ' . $this->li_of[0] . ' OFFSET ' . $this->li_of[1];
642
+                $sql .= 'LIMIT '.$this->li_of[0].' OFFSET '.$this->li_of[1];
646 643
             }
647 644
         }
648 645
         return $this->qiterator = new TableQueryIterator(
@@ -692,7 +689,7 @@  discard block
 block discarded – undo
692 689
                 $ret[$k] = str_repeat(' ', 255);
693 690
                 $par[] = &$ret[$k];
694 691
             }
695
-            $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?'));
692
+            $sql .= ' RETURNING '.implode(',', $primary).' INTO '.implode(',', array_fill(0, count($primary), '?'));
696 693
             $this->db->query($sql, $par);
697 694
             return $ret;
698 695
         } else {
@@ -724,7 +721,7 @@  discard block
 block discarded – undo
724 721
         }
725 722
         $sql = 'UPDATE '.$table.' SET ';
726 723
         $par = [];
727
-        $sql .= implode(', ', array_map(function ($v) { return $v . ' = ?'; }, array_keys($update))) . ' ';
724
+        $sql .= implode(', ', array_map(function($v) { return $v.' = ?'; }, array_keys($update))).' ';
728 725
         $par = array_merge($par, array_values($update));
729 726
         if (count($this->where)) {
730 727
             $sql .= 'WHERE ';
@@ -733,7 +730,7 @@  discard block
 block discarded – undo
733 730
                 $tmp[] = $v[0];
734 731
                 $par = array_merge($par, $v[1]);
735 732
             }
736
-            $sql .= implode(' AND ', $tmp) . ' ';
733
+            $sql .= implode(' AND ', $tmp).' ';
737 734
         }
738 735
         if (count($this->order)) {
739 736
             $sql .= $this->order[0];
@@ -757,7 +754,7 @@  discard block
 block discarded – undo
757 754
                 $tmp[] = $v[0];
758 755
                 $par = array_merge($par, $v[1]);
759 756
             }
760
-            $sql .= implode(' AND ', $tmp) . ' ';
757
+            $sql .= implode(' AND ', $tmp).' ';
761 758
         }
762 759
         if (count($this->order)) {
763 760
             $sql .= $this->order[0];
@@ -777,13 +774,13 @@  discard block
 block discarded – undo
777 774
         $table = $this->definition;
778 775
         array_reduce(
779 776
             $parts,
780
-            function ($carry, $item) use (&$table) {
777
+            function($carry, $item) use (&$table) {
781 778
                 $relation = $table->getRelation($item);
782 779
                 if (!$relation) {
783 780
                     throw new DBException('Invalid relation name');
784 781
                 }
785
-                $name = $carry ? $carry . static::SEP . $item : $item;
786
-                $this->withr[$name] = [ $relation, $carry ?? $table->getName() ];
782
+                $name = $carry ? $carry.static::SEP.$item : $item;
783
+                $this->withr[$name] = [$relation, $carry ?? $table->getName()];
787 784
                 $table = $relation->table;
788 785
                 return $name;
789 786
             }
Please login to merge, or discard this patch.
src/driver/mysql/Statement.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
             }
84 84
         }
85 85
         if (!$this->statement->execute()) {
86
-            throw new DBException('Prepared execute error: ' . $this->statement->error);
86
+            throw new DBException('Prepared execute error: '.$this->statement->error);
87 87
         }
88 88
         return new Result($this->statement);
89 89
     }
Please login to merge, or discard this patch.