Completed
Push — master ( 742aa8...2d5fde )
by Lars
03:26
created
src/voku/db/Prepare.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace voku\db;
6 6
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
     foreach ($this->_boundParams as $param) {
84 84
       $arguments[0] .= $param['type'];
85
-      $arguments[] =& $param['value'];
85
+      $arguments[] = & $param['value'];
86 86
     }
87 87
 
88 88
     return $arguments;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     $value = $this->_db->escape($value);
106 106
 
107 107
     if ($type === 's') {
108
-      $valueForSqlWithBoundParameters = "'" . $value . "'";
108
+      $valueForSqlWithBoundParameters = "'".$value."'";
109 109
     } elseif ($type === 'i') {
110 110
       $valueForSqlWithBoundParameters = (int)$value;
111 111
     } elseif ($type === 'd') {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     // debug_backtrace returns arguments by reference, see comments at http://php.net/manual/de/function.func-get-args.php
183 183
     $trace = \debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1);
184 184
 
185
-    $args =& $trace[0]['args'];
185
+    $args = & $trace[0]['args'];
186 186
     $types = \str_split($types);
187 187
 
188 188
     $args_count = \count($args) - 1;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
     $arg = 1;
198 198
     foreach ($types as $typeInner) {
199
-      $val =& $args[$arg];
199
+      $val = & $args[$arg];
200 200
       $this->_boundParams[] = [
201 201
           'type'  => $typeInner,
202 202
           'value' => &$val,
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
     $bool = parent::prepare($query);
333 333
 
334 334
     if ($bool === false) {
335
-      $this->_debug->displayError('Can not prepare query: ' . $query . ' | ' . $this->error, false);
335
+      $this->_debug->displayError('Can not prepare query: '.$query.' | '.$this->error, false);
336 336
     }
337 337
 
338 338
     return $bool;
@@ -420,11 +420,11 @@  discard block
 block discarded – undo
420 420
 
421 421
       // exit if we have more then 3 "DB server has gone away"-errors
422 422
       if ($RECONNECT_COUNTER > 3) {
423
-        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
423
+        $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg.":\n<br />".$sql, 5);
424 424
         throw new DBGoneAwayException($errorMsg);
425 425
       }
426 426
 
427
-      $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
427
+      $this->_debug->mailToAdmin('DB-Error', $errorMsg.":\n<br />".$sql);
428 428
 
429 429
       // reconnect
430 430
       $RECONNECT_COUNTER++;
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
       return $this->execute();
435 435
     }
436 436
 
437
-    $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
437
+    $this->_debug->mailToAdmin('SQL-Error', $errorMsg.":\n<br />".$sql);
438 438
 
439 439
     // this query returned an error, we must display it (only for dev) !!!
440
-    $this->_debug->displayError($errorMsg . ' | ' . $sql);
440
+    $this->_debug->displayError($errorMsg.' | '.$sql);
441 441
 
442 442
     return false;
443 443
   }
Please login to merge, or discard this patch.
src/voku/db/Helper.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace voku\db;
6 6
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     $optimized = 0;
32 32
     if (!empty($tables)) {
33 33
       foreach ($tables as $table) {
34
-        $optimize = 'OPTIMIZE TABLE ' . $dbConnection->quote_string($table);
34
+        $optimize = 'OPTIMIZE TABLE '.$dbConnection->quote_string($table);
35 35
         $result = $dbConnection->query($optimize);
36 36
         if ($result) {
37 37
           $optimized++;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     $optimized = 0;
60 60
     if (!empty($tables)) {
61 61
       foreach ($tables as $table) {
62
-        $optimize = 'REPAIR TABLE ' . $dbConnection->quote_string($table);
62
+        $optimize = 'REPAIR TABLE '.$dbConnection->quote_string($table);
63 63
         $result = $dbConnection->query($optimize);
64 64
         if ($result) {
65 65
           $optimized++;
@@ -176,23 +176,23 @@  discard block
 block discarded – undo
176 176
 
177 177
     $whereSQL = $dbConnection->_parseArrayPair($whereArray, 'AND');
178 178
     if ($whereSQL) {
179
-      $whereSQL = 'AND ' . $whereSQL;
179
+      $whereSQL = 'AND '.$whereSQL;
180 180
     }
181 181
 
182 182
     if ($databaseName) {
183
-      $databaseName = $dbConnection->quote_string(trim($databaseName)) . '.';
183
+      $databaseName = $dbConnection->quote_string(trim($databaseName)).'.';
184 184
     }
185 185
 
186 186
     // get the row
187
-    $query = 'SELECT ' . $dbConnection->quote_string($searchFieldName) . ', ' . $dbConnection->quote_string($idFieldName) . ' 
188
-      FROM ' . $databaseName . $dbConnection->quote_string($table) . '
187
+    $query = 'SELECT '.$dbConnection->quote_string($searchFieldName).', '.$dbConnection->quote_string($idFieldName).' 
188
+      FROM ' . $databaseName.$dbConnection->quote_string($table).'
189 189
       WHERE 1 = 1
190
-      ' . $whereSQL . '
190
+      ' . $whereSQL.'
191 191
     ';
192 192
 
193 193
     if ($useCache === true) {
194 194
       $cache = new Cache(null, null, false, $useCache);
195
-      $cacheKey = 'sql-phonetic-search-' . \md5($query);
195
+      $cacheKey = 'sql-phonetic-search-'.\md5($query);
196 196
 
197 197
       if (
198 198
           $cache->getCacheIsReady() === true
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
     }
323 323
 
324 324
     if ($databaseName) {
325
-      $databaseName = $dbConnection->quote_string(trim($databaseName)) . '.';
325
+      $databaseName = $dbConnection->quote_string(trim($databaseName)).'.';
326 326
     }
327 327
 
328
-    $sql = 'SHOW COLUMNS FROM ' . $databaseName . $dbConnection->escape($table);
328
+    $sql = 'SHOW COLUMNS FROM '.$databaseName.$dbConnection->escape($table);
329 329
     $result = $dbConnection->query($sql);
330 330
 
331 331
     if ($result && $result->num_rows > 0) {
@@ -371,17 +371,17 @@  discard block
 block discarded – undo
371 371
 
372 372
     $whereSQL = $dbConnection->_parseArrayPair($whereArray, 'AND');
373 373
     if ($whereSQL) {
374
-      $whereSQL = 'AND ' . $whereSQL;
374
+      $whereSQL = 'AND '.$whereSQL;
375 375
     }
376 376
 
377 377
     if ($databaseName) {
378
-      $databaseName = $dbConnection->quote_string(trim($databaseName)) . '.';
378
+      $databaseName = $dbConnection->quote_string(trim($databaseName)).'.';
379 379
     }
380 380
 
381 381
     // get the row
382
-    $query = 'SELECT * FROM ' . $databaseName . $dbConnection->quote_string($table) . '
382
+    $query = 'SELECT * FROM '.$databaseName.$dbConnection->quote_string($table).'
383 383
       WHERE 1 = 1
384
-      ' . $whereSQL . '
384
+      ' . $whereSQL.'
385 385
     ';
386 386
     $result = $dbConnection->query($query);
387 387
 
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 
402 402
           if (!\in_array($fieldName, $ignoreArray, true)) {
403 403
             if (\array_key_exists($fieldName, $updateArray)) {
404
-              $insert_keys .= ',' . $fieldName;
404
+              $insert_keys .= ','.$fieldName;
405 405
               $insert_values .= ',?';
406 406
               $bindings[] = $updateArray[$fieldName]; // INFO: do not escape non selected data
407 407
             } else {
408
-              $insert_keys .= ',' . $fieldName;
408
+              $insert_keys .= ','.$fieldName;
409 409
               $insert_values .= ',?';
410 410
               $bindings[] = $value; // INFO: do not escape non selected data
411 411
             }
@@ -416,10 +416,10 @@  discard block
 block discarded – undo
416 416
         $insert_values = ltrim($insert_values, ',');
417 417
 
418 418
         // insert the "copied" row
419
-        $new_query = 'INSERT INTO ' . $databaseName . $dbConnection->quote_string($table) . ' 
420
-          (' . $insert_keys . ')
419
+        $new_query = 'INSERT INTO '.$databaseName.$dbConnection->quote_string($table).' 
420
+          (' . $insert_keys.')
421 421
           VALUES 
422
-          (' . $insert_values . ')
422
+          (' . $insert_values.')
423 423
         ';
424 424
 
425 425
         return $dbConnection->query($new_query, $bindings);
Please login to merge, or discard this patch.
src/voku/db/ActiveRecord.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare(strict_types=1);
3
+declare(strict_types = 1);
4 4
 
5 5
 namespace voku\db;
6 6
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
     $value = $this->_filterParam($this->dirty);
584 584
     $this->insert = new ActiveRecordExpressions(
585 585
         [
586
-            'operator' => 'INSERT INTO ' . $this->table,
586
+            'operator' => 'INSERT INTO '.$this->table,
587 587
             'target'   => new ActiveRecordExpressionsWrap(['target' => \array_keys($this->dirty)]),
588 588
         ]
589 589
     );
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
         null === $o->{$n}
795 795
     ) {
796 796
 
797
-      $n = \strtoupper($n) . ' ' . $o->table . '.*';
797
+      $n = \strtoupper($n).' '.$o->table.'.*';
798 798
 
799 799
     } elseif (
800 800
         (
@@ -806,15 +806,15 @@  discard block
 block discarded – undo
806 806
         null === $o->{$n}
807 807
     ) {
808 808
 
809
-      $n = \strtoupper($n) . ' ' . $o->table;
809
+      $n = \strtoupper($n).' '.$o->table;
810 810
 
811 811
     } elseif ('delete' === $n) {
812 812
 
813
-      $n = \strtoupper($n) . ' ';
813
+      $n = \strtoupper($n).' ';
814 814
 
815 815
     } else {
816 816
 
817
-      $n = (null !== $o->{$n}) ? $o->{$n} . ' ' : '';
817
+      $n = (null !== $o->{$n}) ? $o->{$n}.' ' : '';
818 818
 
819 819
     }
820 820
   }
@@ -927,10 +927,10 @@  discard block
 block discarded – undo
927 927
   {
928 928
     if (\is_array($value)) {
929 929
       foreach ($value as $key => $val) {
930
-        $this->params[$value[$key] = self::PREFIX . ++self::$count] = $val;
930
+        $this->params[$value[$key] = self::PREFIX.++self::$count] = $val;
931 931
       }
932 932
     } elseif (\is_string($value)) {
933
-      $this->params[$ph = self::PREFIX . ++self::$count] = $value;
933
+      $this->params[$ph = self::PREFIX.++self::$count] = $value;
934 934
       $value = $ph;
935 935
     }
936 936
 
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
     $value = $this->_filterParam($value);
952 952
     $exp = new ActiveRecordExpressions(
953 953
         [
954
-            'source'   => ('where' == $name ? $this->table . '.' : '') . $field,
954
+            'source'   => ('where' == $name ? $this->table.'.' : '').$field,
955 955
             'operator' => $operator,
956 956
             'target'   => \is_array($value)
957 957
                 ? new ActiveRecordExpressionsWrap(
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
     $this->join = new ActiveRecordExpressions(
985 985
         [
986 986
             'source'   => $this->join ?: '',
987
-            'operator' => $type . ' JOIN',
987
+            'operator' => $type.' JOIN',
988 988
             'target'   => new ActiveRecordExpressions(
989 989
                 ['source' => $table, 'operator' => 'ON', 'target' => $on]
990 990
             ),
Please login to merge, or discard this patch.