Completed
Pull Request — master (#12)
by
unknown
02:53
created
src/voku/db/DB.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -296,12 +296,12 @@  discard block
 block discarded – undo
296 296
           $this->socket
297 297
       );
298 298
     } catch (\Exception $e) {
299
-      $this->_displayError('Error connecting to mysql server: ' . $e->getMessage(), true);
299
+      $this->_displayError('Error connecting to mysql server: '.$e->getMessage(), true);
300 300
     }
301 301
     mysqli_report(MYSQLI_REPORT_OFF);
302 302
 
303 303
     if (!$this->link) {
304
-      $this->_displayError('Error connecting to mysql server: ' . mysqli_connect_error(), true);
304
+      $this->_displayError('Error connecting to mysql server: '.mysqli_connect_error(), true);
305 305
     } else {
306 306
       $this->set_charset($this->charset);
307 307
       $this->connected = true;
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
     $this->logger(
336 336
         array(
337 337
             'error',
338
-            '<strong>' . date(
338
+            '<strong>'.date(
339 339
                 'd. m. Y G:i:s'
340
-            ) . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . ') (sql-error):</strong> ' . $error . '<br>',
340
+            ).' ('.$fileInfo['file'].' line: '.$fileInfo['line'].') (sql-error):</strong> '.$error.'<br>',
341 341
         )
342 342
     );
343 343
 
@@ -350,11 +350,11 @@  discard block
 block discarded – undo
350 350
         $box_bg = $this->css_mysql_box_bg;
351 351
 
352 352
         echo '
353
-        <div class="OBJ-mysql-box" style="border:' . $box_border . '; background:' . $box_bg . '; padding:10px; margin:10px;">
353
+        <div class="OBJ-mysql-box" style="border:' . $box_border.'; background:'.$box_bg.'; padding:10px; margin:10px;">
354 354
           <b style="font-size:14px;">MYSQL Error:</b>
355 355
           <code style="display:block;">
356
-            file / line: ' . $fileInfo['file'] . ' / ' . $fileInfo['line'] . '
357
-            ' . $error . '
356
+            file / line: ' . $fileInfo['file'].' / '.$fileInfo['line'].'
357
+            ' . $error.'
358 358
           </code>
359 359
         </div>
360 360
         ';
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
     static $firstInstance = null;
572 572
 
573 573
     if (
574
-        $hostname . $username . $password . $database . $port . $charset == ''
574
+        $hostname.$username.$password.$database.$port.$charset == ''
575 575
         &&
576 576
         null !== $firstInstance
577 577
     ) {
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
     }
580 580
 
581 581
     $connection = md5(
582
-        $hostname . $username . $password . $database . $port . $charset . (int)$exit_on_error . (int)$echo_on_error . $logger_class_name . $logger_level . (int)$session_to_db
582
+        $hostname.$username.$password.$database.$port.$charset.(int)$exit_on_error.(int)$echo_on_error.$logger_class_name.$logger_level.(int)$session_to_db
583 583
     );
584 584
 
585 585
     if (!isset($instance[$connection])) {
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
       // "string"
763 763
 
764 764
       if (!in_array($var, $this->mysqlDefaultTimeFunctions, true)) {
765
-        $var = "'" . trim($this->escape(trim(trim((string)$var), "'")), "'") . "'";
765
+        $var = "'".trim($this->escape(trim(trim((string)$var), "'")), "'")."'";
766 766
       }
767 767
 
768 768
     } elseif (is_float($var)) {
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
       // "DateTime"-object
783 783
 
784 784
       try {
785
-        $var = "'" . $this->escape($var->format('Y-m-d H:i:s'), false, false) . "'";
785
+        $var = "'".$this->escape($var->format('Y-m-d H:i:s'), false, false)."'";
786 786
       } catch (\Exception $e) {
787 787
         $var = null;
788 788
       }
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 
792 792
       // fallback ...
793 793
 
794
-      $var = "'" . trim($this->escape(trim(trim((string)$var), "'")), "'") . "'";
794
+      $var = "'".trim($this->escape(trim(trim((string)$var), "'")), "'")."'";
795 795
 
796 796
     }
797 797
 
@@ -913,13 +913,13 @@  discard block
 block discarded – undo
913 913
       return false;
914 914
     }
915 915
 
916
-    $info = 'time => ' . round($duration, 5) . ' - ' . 'results => ' . $results . ' - ' . 'SQL => ' . UTF8::htmlentities($sql);
916
+    $info = 'time => '.round($duration, 5).' - '.'results => '.$results.' - '.'SQL => '.UTF8::htmlentities($sql);
917 917
     $fileInfo = $this->getFileAndLineFromSql();
918 918
 
919 919
     $this->logger(
920 920
         array(
921 921
             'debug',
922
-            '<strong>' . date('d. m. Y G:i:s') . ' (' . $fileInfo['file'] . ' line: ' . $fileInfo['line'] . '):</strong> ' . $info . '<br>',
922
+            '<strong>'.date('d. m. Y G:i:s').' ('.$fileInfo['file'].' line: '.$fileInfo['line'].'):</strong> '.$info.'<br>',
923 923
             'sql',
924 924
         )
925 925
     );
@@ -963,10 +963,10 @@  discard block
 block discarded – undo
963 963
 
964 964
       // exit if we have more then 3 "DB server has gone away"-errors
965 965
       if ($reconnectCounter > 3) {
966
-        $this->mailToAdmin('SQL-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
966
+        $this->mailToAdmin('SQL-Fatal-Error', $errorMsg.":\n<br />".$sql, 5);
967 967
         throw new \Exception($errorMsg);
968 968
       } else {
969
-        $this->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
969
+        $this->mailToAdmin('SQL-Error', $errorMsg.":\n<br />".$sql);
970 970
 
971 971
         // reconnect
972 972
         $reconnectCounter++;
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
         $this->query($sql, $sqlParams);
977 977
       }
978 978
     } else {
979
-      $this->mailToAdmin('SQL-Warning', $errorMsg . ":\n<br />" . $sql);
979
+      $this->mailToAdmin('SQL-Warning', $errorMsg.":\n<br />".$sql);
980 980
 
981 981
       // this query returned an error, we must display it (only for dev) !!!
982
-      $this->_displayError($errorMsg . ' | ' . $sql);
982
+      $this->_displayError($errorMsg.' | '.$sql);
983 983
     }
984 984
   }
985 985
 
@@ -1000,21 +1000,21 @@  discard block
 block discarded – undo
1000 1000
         $this->logger(
1001 1001
             array(
1002 1002
                 'debug',
1003
-                $subject . ' | ' . $htmlBody,
1003
+                $subject.' | '.$htmlBody,
1004 1004
             )
1005 1005
         );
1006 1006
       } elseif ($priority > 3) {
1007 1007
         $this->logger(
1008 1008
             array(
1009 1009
                 'error',
1010
-                $subject . ' | ' . $htmlBody,
1010
+                $subject.' | '.$htmlBody,
1011 1011
             )
1012 1012
         );
1013 1013
       } elseif ($priority < 3) {
1014 1014
         $this->logger(
1015 1015
             array(
1016 1016
                 'info',
1017
-                $subject . ' | ' . $htmlBody,
1017
+                $subject.' | '.$htmlBody,
1018 1018
             )
1019 1019
         );
1020 1020
       }
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 
1086 1086
     if ($useCache === true) {
1087 1087
       $cache = new Cache(null, null, false, $useCache);
1088
-      $cacheKey = 'sql-' . md5($query);
1088
+      $cacheKey = 'sql-'.md5($query);
1089 1089
 
1090 1090
       if (
1091 1091
           $cache->getCacheIsReady() === true
@@ -1147,9 +1147,9 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
     $return = mysqli_set_charset($this->link, $charset);
1149 1149
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
1150
-    @mysqli_query($this->link, 'SET CHARACTER SET ' . $charset);
1150
+    @mysqli_query($this->link, 'SET CHARACTER SET '.$charset);
1151 1151
     /** @noinspection PhpUsageOfSilenceOperatorInspection */
1152
-    @mysqli_query($this->link, "SET NAMES '" . ($charset == 'utf8' ? 'utf8mb4' : $charset) . "'");
1152
+    @mysqli_query($this->link, "SET NAMES '".($charset == 'utf8' ? 'utf8mb4' : $charset)."'");
1153 1153
 
1154 1154
     return $return;
1155 1155
   }
@@ -1240,10 +1240,10 @@  discard block
 block discarded – undo
1240 1240
 
1241 1241
       if ($this->checkForDev() === true) {
1242 1242
         echo "Info: maybe you have to increase your 'max_allowed_packet = 30M' in the config: 'my.conf' \n<br />";
1243
-        echo 'Error:' . $errorMsg;
1243
+        echo 'Error:'.$errorMsg;
1244 1244
       }
1245 1245
 
1246
-      $this->mailToAdmin('SQL-Error in mysqli_multi_query', $errorMsg . ":\n<br />" . $sql);
1246
+      $this->mailToAdmin('SQL-Error in mysqli_multi_query', $errorMsg.":\n<br />".$sql);
1247 1247
     }
1248 1248
 
1249 1249
     // return the result only if there was a "SELECT"-query
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 
1281 1281
       return false;
1282 1282
     } elseif (mysqli_connect_errno()) {
1283
-      $this->_displayError('Error connecting to mysql server: ' . mysqli_connect_error(), true);
1283
+      $this->_displayError('Error connecting to mysql server: '.mysqli_connect_error(), true);
1284 1284
 
1285 1285
       return false;
1286 1286
     } else {
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 
1391 1391
     $SET = $this->_parseArrayPair($data);
1392 1392
 
1393
-    $sql = 'INSERT '.($ignore?'IGNORE':''). 'INTO ' . $this->quote_string($table) . " SET $SET;";
1393
+    $sql = 'INSERT '.($ignore ? 'IGNORE' : '').'INTO '.$this->quote_string($table)." SET $SET;";
1394 1394
 
1395 1395
     return $this->query($sql);
1396 1396
   }
@@ -1484,7 +1484,7 @@  discard block
 block discarded – undo
1484 1484
             /** @noinspection AlterInForeachInspection */
1485 1485
             $_value[$oldKey] = $this->secure($oldValue);
1486 1486
           }
1487
-          $_value = '(' . implode(',', $_value) . ')';
1487
+          $_value = '('.implode(',', $_value).')';
1488 1488
         } elseif (
1489 1489
             is_array($_value)
1490 1490
             &&
@@ -1498,13 +1498,13 @@  discard block
 block discarded – undo
1498 1498
             /** @noinspection AlterInForeachInspection */
1499 1499
             $_value[$oldKey] = $this->secure($oldValue);
1500 1500
           }
1501
-          $_value = '(' . implode(' AND ', $_value) . ')';
1501
+          $_value = '('.implode(' AND ', $_value).')';
1502 1502
         } else {
1503 1503
           $_value = $this->secure($_value);
1504 1504
         }
1505 1505
 
1506 1506
         $quoteString = $this->quote_string(trim(str_ireplace($_connector, '', $_key)));
1507
-        $pairs[] = ' ' . $quoteString . ' ' . $_connector . ' ' . $_value . " \n";
1507
+        $pairs[] = ' '.$quoteString.' '.$_connector.' '.$_value." \n";
1508 1508
       }
1509 1509
 
1510 1510
       $sql = implode($glue, $pairs);
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
    */
1523 1523
   public function quote_string($str)
1524 1524
   {
1525
-    return '`' . $this->escape($str, false, false) . '`';
1525
+    return '`'.$this->escape($str, false, false).'`';
1526 1526
   }
1527 1527
 
1528 1528
   /**
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
     }
1577 1577
     $values = implode(',', $data);
1578 1578
 
1579
-    $sql = 'REPLACE INTO ' . $this->quote_string($table) . " ($columns) VALUES ($values);";
1579
+    $sql = 'REPLACE INTO '.$this->quote_string($table)." ($columns) VALUES ($values);";
1580 1580
 
1581 1581
     return $this->query($sql);
1582 1582
   }
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
       $WHERE = '';
1617 1617
     }
1618 1618
 
1619
-    $sql = 'UPDATE ' . $this->quote_string($table) . " SET $SET WHERE ($WHERE);";
1619
+    $sql = 'UPDATE '.$this->quote_string($table)." SET $SET WHERE ($WHERE);";
1620 1620
 
1621 1621
     return $this->query($sql);
1622 1622
   }
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
       $WHERE = '';
1649 1649
     }
1650 1650
 
1651
-    $sql = 'DELETE FROM ' . $this->quote_string($table) . " WHERE ($WHERE);";
1651
+    $sql = 'DELETE FROM '.$this->quote_string($table)." WHERE ($WHERE);";
1652 1652
 
1653 1653
     return $this->query($sql);
1654 1654
   }
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
       $WHERE = '';
1679 1679
     }
1680 1680
 
1681
-    $sql = 'SELECT * FROM ' . $this->quote_string($table) . " WHERE ($WHERE);";
1681
+    $sql = 'SELECT * FROM '.$this->quote_string($table)." WHERE ($WHERE);";
1682 1682
 
1683 1683
     return $this->query($sql);
1684 1684
   }
Please login to merge, or discard this patch.