Completed
Push — master ( 86cd12...911a79 )
by Lars
02:29
created
src/voku/db/Result.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -229,7 +229,7 @@
 block discarded – undo
229 229
    * fetchObject
230 230
    *
231 231
    * @param string     $class
232
-   * @param null|array $params
232
+   * @param string $params
233 233
    * @param bool       $reset
234 234
    *
235 235
    * @return object|false false on error
Please login to merge, or discard this patch.
src/voku/db/DB.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
    * @param bool  $html_entity_decode
811 811
    * @param bool  $array_to_string
812 812
    *
813
-   * @return array|bool|float|int|string
813
+   * @return string
814 814
    */
815 815
   public function escape($var = '', $stripe_non_utf8 = true, $html_entity_decode = true, $array_to_string = false)
816 816
   {
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
   /**
931 931
    * Returns the auto generated id used in the last query.
932 932
    *
933
-   * @return int|string
933
+   * @return integer
934 934
    */
935 935
   public function insert_id()
936 936
   {
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
           $this->socket
299 299
       );
300 300
     } catch (\Exception $e) {
301
-      $this->_displayError('Error connecting to mysql server: ' . $e->getMessage(), true);
301
+      $this->_displayError('Error connecting to mysql server: '.$e->getMessage(), true);
302 302
     }
303 303
     mysqli_report(MYSQLI_REPORT_OFF);
304 304
 
305 305
     if (!$this->connected) {
306
-      $this->_displayError('Error connecting to mysql server: ' . mysqli_connect_error(), true);
306
+      $this->_displayError('Error connecting to mysql server: '.mysqli_connect_error(), true);
307 307
     } else {
308 308
       $this->set_charset($this->charset);
309 309
     }
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
     $this->logger(
337 337
         array(
338 338
             'error',
339
-            '<strong>' . date(
339
+            '<strong>'.date(
340 340
                 'd. m. Y G:i:s'
341
-            ) . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . ') (sql-error):</strong> ' . $error . '<br>',
341
+            ).' ('.$fileInfo['file'].' line: '.$fileInfo['line'].') (sql-error):</strong> '.$error.'<br>',
342 342
         )
343 343
     );
344 344
 
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
         $box_bg = $this->css_mysql_box_bg;
352 352
 
353 353
         echo '
354
-        <div class="OBJ-mysql-box" style="border:' . $box_border . '; background:' . $box_bg . '; padding:10px; margin:10px;">
354
+        <div class="OBJ-mysql-box" style="border:' . $box_border.'; background:'.$box_bg.'; padding:10px; margin:10px;">
355 355
           <b style="font-size:14px;">MYSQL Error:</b>
356 356
           <code style="display:block;">
357
-            file / line: ' . $fileInfo['file'] . ' / ' . $fileInfo['line'] . '
358
-            ' . $error . '
357
+            file / line: ' . $fileInfo['file'].' / '.$fileInfo['line'].'
358
+            ' . $error.'
359 359
           </code>
360 360
         </div>
361 361
         ';
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
     static $firstInstance = null;
573 573
 
574 574
     if (
575
-        $hostname . $username . $password . $database . $port . $charset == ''
575
+        $hostname.$username.$password.$database.$port.$charset == ''
576 576
         &&
577 577
         null !== $firstInstance
578 578
     ) {
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     }
581 581
 
582 582
     $connection = md5(
583
-        $hostname . $username . $password . $database . $port . $charset . (int)$exit_on_error . (int)$echo_on_error . $logger_class_name . $logger_level . (int)$session_to_db
583
+        $hostname.$username.$password.$database.$port.$charset.(int)$exit_on_error.(int)$echo_on_error.$logger_class_name.$logger_level.(int)$session_to_db
584 584
     );
585 585
 
586 586
     if (!isset($instance[$connection])) {
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
       // "string"
760 760
 
761 761
       if (!in_array($var, $this->mysqlDefaultTimeFunctions, true)) {
762
-        $var = "'" . trim($this->escape(trim(trim((string)$var), "'")), "'") . "'";
762
+        $var = "'".trim($this->escape(trim(trim((string)$var), "'")), "'")."'";
763 763
       }
764 764
 
765 765
     } elseif (is_float($var)) {
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
       // "DateTime"-object
780 780
 
781 781
       try {
782
-        $var = "'" . $this->escape($var->format('Y-m-d H:i:s'), false, false) . "'";
782
+        $var = "'".$this->escape($var->format('Y-m-d H:i:s'), false, false)."'";
783 783
       } catch (\Exception $e) {
784 784
         $var = null;
785 785
       }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 
789 789
       // fallback ...
790 790
 
791
-      $var = "'" . trim($this->escape(trim(trim((string)$var), "'")), "'") . "'";
791
+      $var = "'".trim($this->escape(trim(trim((string)$var), "'")), "'")."'";
792 792
 
793 793
     }
794 794
 
@@ -912,16 +912,16 @@  discard block
 block discarded – undo
912 912
 
913 913
     $infoExtra = mysqli_info($this->link);
914 914
     if ($infoExtra) {
915
-      $infoExtra = ' | info => ' . $infoExtra;
915
+      $infoExtra = ' | info => '.$infoExtra;
916 916
     }
917 917
 
918
-    $info = 'time => ' . round($duration, 5) . ' | results => ' . (int)$results . $infoExtra . ' | SQL => ' . UTF8::htmlentities($sql);
918
+    $info = 'time => '.round($duration, 5).' | results => '.(int)$results.$infoExtra.' | SQL => '.UTF8::htmlentities($sql);
919 919
     $fileInfo = $this->getFileAndLineFromSql();
920 920
 
921 921
     $this->logger(
922 922
         array(
923 923
             'debug',
924
-            '<strong>' . date('d. m. Y G:i:s') . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . '):</strong> ' . $info . '<br>',
924
+            '<strong>'.date('d. m. Y G:i:s').' ('.$fileInfo['file'].' line: '.$fileInfo['line'].'):</strong> '.$info.'<br>',
925 925
             'sql',
926 926
         )
927 927
     );
@@ -965,10 +965,10 @@  discard block
 block discarded – undo
965 965
 
966 966
       // exit if we have more then 3 "DB server has gone away"-errors
967 967
       if ($reconnectCounter > 3) {
968
-        $this->mailToAdmin('SQL-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
968
+        $this->mailToAdmin('SQL-Fatal-Error', $errorMsg.":\n<br />".$sql, 5);
969 969
         throw new \Exception($errorMsg);
970 970
       } else {
971
-        $this->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
971
+        $this->mailToAdmin('SQL-Error', $errorMsg.":\n<br />".$sql);
972 972
 
973 973
         // reconnect
974 974
         $reconnectCounter++;
@@ -978,10 +978,10 @@  discard block
 block discarded – undo
978 978
         $this->query($sql, $sqlParams);
979 979
       }
980 980
     } else {
981
-      $this->mailToAdmin('SQL-Warning', $errorMsg . ":\n<br />" . $sql);
981
+      $this->mailToAdmin('SQL-Warning', $errorMsg.":\n<br />".$sql);
982 982
 
983 983
       // this query returned an error, we must display it (only for dev) !!!
984
-      $this->_displayError($errorMsg . ' | ' . $sql);
984
+      $this->_displayError($errorMsg.' | '.$sql);
985 985
     }
986 986
   }
987 987
 
@@ -1002,21 +1002,21 @@  discard block
 block discarded – undo
1002 1002
         $this->logger(
1003 1003
             array(
1004 1004
                 'debug',
1005
-                $subject . ' | ' . $htmlBody,
1005
+                $subject.' | '.$htmlBody,
1006 1006
             )
1007 1007
         );
1008 1008
       } elseif ($priority > 3) {
1009 1009
         $this->logger(
1010 1010
             array(
1011 1011
                 'error',
1012
-                $subject . ' | ' . $htmlBody,
1012
+                $subject.' | '.$htmlBody,
1013 1013
             )
1014 1014
         );
1015 1015
       } elseif ($priority < 3) {
1016 1016
         $this->logger(
1017 1017
             array(
1018 1018
                 'info',
1019
-                $subject . ' | ' . $htmlBody,
1019
+                $subject.' | '.$htmlBody,
1020 1020
             )
1021 1021
         );
1022 1022
       }
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 
1088 1088
     if ($useCache === true) {
1089 1089
       $cache = new Cache(null, null, false, $useCache);
1090
-      $cacheKey = 'sql-' . md5($query);
1090
+      $cacheKey = 'sql-'.md5($query);
1091 1091
 
1092 1092
       if (
1093 1093
           $cache->getCacheIsReady() === true
@@ -1149,9 +1149,9 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
     $return = mysqli_set_charset($this->link, $charset);
1151 1151
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
1152
-    @mysqli_query($this->link, 'SET CHARACTER SET ' . $charset);
1152
+    @mysqli_query($this->link, 'SET CHARACTER SET '.$charset);
1153 1153
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
1154
-    @mysqli_query($this->link, "SET NAMES '" . ($charset === 'utf8' ? 'utf8mb4' : $charset) . "'");
1154
+    @mysqli_query($this->link, "SET NAMES '".($charset === 'utf8' ? 'utf8mb4' : $charset)."'");
1155 1155
 
1156 1156
     return $return;
1157 1157
   }
@@ -1238,10 +1238,10 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
       if ($this->checkForDev() === true) {
1240 1240
         echo "Info: maybe you have to increase your 'max_allowed_packet = 30M' in the config: 'my.conf' \n<br />";
1241
-        echo 'Error:' . $errorMsg;
1241
+        echo 'Error:'.$errorMsg;
1242 1242
       }
1243 1243
 
1244
-      $this->mailToAdmin('SQL-Error in mysqli_multi_query', $errorMsg . ":\n<br />" . $sql);
1244
+      $this->mailToAdmin('SQL-Error in mysqli_multi_query', $errorMsg.":\n<br />".$sql);
1245 1245
     }
1246 1246
 
1247 1247
     // return the result only if there was a "SELECT"-query
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 
1279 1279
       return false;
1280 1280
     } elseif (mysqli_connect_errno()) {
1281
-      $this->_displayError('Error connecting to mysql server: ' . mysqli_connect_error(), true);
1281
+      $this->_displayError('Error connecting to mysql server: '.mysqli_connect_error(), true);
1282 1282
 
1283 1283
       return false;
1284 1284
     } else {
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 
1388 1388
     $SET = $this->_parseArrayPair($data);
1389 1389
 
1390
-    $sql = 'INSERT INTO ' . $this->quote_string($table) . " SET $SET;";
1390
+    $sql = 'INSERT INTO '.$this->quote_string($table)." SET $SET;";
1391 1391
 
1392 1392
     return $this->query($sql);
1393 1393
   }
@@ -1474,9 +1474,9 @@  discard block
 block discarded – undo
1474 1474
           }
1475 1475
 
1476 1476
           if ($_connector === 'NOT IN' || $_connector === 'IN') {
1477
-            $_value = '(' . implode(',', $_value) . ')';
1477
+            $_value = '('.implode(',', $_value).')';
1478 1478
           } elseif ($_connector === 'NOT BETWEEN' || $_connector === 'BETWEEN') {
1479
-            $_value = '(' . implode(' AND ', $_value) . ')';
1479
+            $_value = '('.implode(' AND ', $_value).')';
1480 1480
           }
1481 1481
 
1482 1482
         } else {
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
         }
1485 1485
 
1486 1486
         $quoteString = $this->quote_string(trim(str_ireplace($_connector, '', $_key)));
1487
-        $pairs[] = ' ' . $quoteString . ' ' . $_connector . ' ' . $_value . " \n";
1487
+        $pairs[] = ' '.$quoteString.' '.$_connector.' '.$_value." \n";
1488 1488
       }
1489 1489
 
1490 1490
       $sql = implode($glue, $pairs);
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
    */
1503 1503
   public function quote_string($str)
1504 1504
   {
1505
-    return '`' . $this->escape($str, false, false) . '`';
1505
+    return '`'.$this->escape($str, false, false).'`';
1506 1506
   }
1507 1507
 
1508 1508
   /**
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
     }
1557 1557
     $values = implode(',', $data);
1558 1558
 
1559
-    $sql = 'REPLACE INTO ' . $this->quote_string($table) . " ($columns) VALUES ($values);";
1559
+    $sql = 'REPLACE INTO '.$this->quote_string($table)." ($columns) VALUES ($values);";
1560 1560
 
1561 1561
     return $this->query($sql);
1562 1562
   }
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
       $WHERE = '';
1597 1597
     }
1598 1598
 
1599
-    $sql = 'UPDATE ' . $this->quote_string($table) . " SET $SET WHERE ($WHERE);";
1599
+    $sql = 'UPDATE '.$this->quote_string($table)." SET $SET WHERE ($WHERE);";
1600 1600
 
1601 1601
     return $this->query($sql);
1602 1602
   }
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
       $WHERE = '';
1629 1629
     }
1630 1630
 
1631
-    $sql = 'DELETE FROM ' . $this->quote_string($table) . " WHERE ($WHERE);";
1631
+    $sql = 'DELETE FROM '.$this->quote_string($table)." WHERE ($WHERE);";
1632 1632
 
1633 1633
     return $this->query($sql);
1634 1634
   }
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
       $WHERE = '';
1659 1659
     }
1660 1660
 
1661
-    $sql = 'SELECT * FROM ' . $this->quote_string($table) . " WHERE ($WHERE);";
1661
+    $sql = 'SELECT * FROM '.$this->quote_string($table)." WHERE ($WHERE);";
1662 1662
 
1663 1663
     return $this->query($sql);
1664 1664
   }
Please login to merge, or discard this patch.
src/voku/db/Helper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     $dbFields = array();
36 36
     $db = DB::getInstance();
37 37
 
38
-    $sql = 'SHOW COLUMNS FROM `' . $db->escape($table) . '`';
38
+    $sql = 'SHOW COLUMNS FROM `'.$db->escape($table).'`';
39 39
     $result = $db->query($sql);
40 40
 
41 41
     if ($result && $result->num_rows > 0) {
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
     $table = $db->escape($table);
72 72
 
73 73
     foreach ($whereArray as $key => $value) {
74
-      $whereSQL = ' AND ' . $db->escape($key) . ' = ' . $db->escape($value);
74
+      $whereSQL = ' AND '.$db->escape($key).' = '.$db->escape($value);
75 75
     }
76 76
 
77 77
     // get the row
78
-    $query = 'SELECT * FROM ' . $table . '
78
+    $query = 'SELECT * FROM '.$table.'
79 79
       WHERE 1 = 1
80
-      ' . $whereSQL . '
80
+      ' . $whereSQL.'
81 81
     ';
82 82
     $result = $db->query($query);
83 83
 
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
             if (array_key_exists($fieldName, $updateArray)) {
98 98
 
99 99
               if ($updateArray[$fieldName] || $updateArray[$fieldName] == 0) {
100
-                $insert_keys .= ',' . $fieldName;
100
+                $insert_keys .= ','.$fieldName;
101 101
                 $insert_values .= ',?';
102 102
                 $bindings[] = $updateArray[$fieldName];
103 103
               }
104 104
 
105 105
             } else {
106
-              $insert_keys .= ',' . $fieldName;
106
+              $insert_keys .= ','.$fieldName;
107 107
               $insert_values .= ',?';
108 108
               $bindings[] = $value;
109 109
             }
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
         }
112 112
 
113 113
         // insert the "copied" row
114
-        $new_query = 'INSERT INTO `' . $table . '` (' . ltrim($insert_keys, ',') . ')
115
-          VALUES (' . ltrim($insert_values, ',') . ')
114
+        $new_query = 'INSERT INTO `'.$table.'` ('.ltrim($insert_keys, ',').')
115
+          VALUES (' . ltrim($insert_values, ',').')
116 116
         ';
117 117
         $return = $db->query($new_query, $bindings);
118 118
       }
Please login to merge, or discard this patch.