Completed
Push — master ( 54db38...e6245f )
by Lars
01:29
created
src/voku/db/Prepare.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
         $value = $this->_db->escape($value);
102 102
 
103 103
         if ($type === 's') {
104
-            $valueForSqlWithBoundParameters = "'" . $value . "'";
104
+            $valueForSqlWithBoundParameters = "'".$value."'";
105 105
         } elseif ($type === 'i') {
106
-            $valueForSqlWithBoundParameters = (int) $value;
106
+            $valueForSqlWithBoundParameters = (int)$value;
107 107
         } elseif ($type === 'd') {
108
-            $valueForSqlWithBoundParameters = (float) $value;
108
+            $valueForSqlWithBoundParameters = (float)$value;
109 109
         } else {
110 110
             $valueForSqlWithBoundParameters = $value;
111 111
         }
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
             // "INSERT" || "REPLACE"
206 206
             if (\preg_match('/^\s*"?(INSERT|REPLACE)\s+/i', $this->_sql)) {
207
-                $insert_id = (int) $this->insert_id;
207
+                $insert_id = (int)$this->insert_id;
208 208
                 $this->_debug->logQuery($this->_sql_with_bound_parameters, $query_duration, $insert_id);
209 209
 
210 210
                 return $insert_id;
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
             // "UPDATE" || "DELETE"
214 214
             if (\preg_match('/^\s*"?(UPDATE|DELETE)\s+/i', $this->_sql)) {
215
-                $affected_rows = (int) $this->affected_rows;
215
+                $affected_rows = (int)$this->affected_rows;
216 216
                 $this->_debug->logQuery($this->_sql_with_bound_parameters, $query_duration, $affected_rows);
217 217
 
218 218
                 return $affected_rows;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
                     return $this->queryErrorHandling($this->error, $this->_sql_with_bound_parameters);
230 230
                 }
231 231
 
232
-                $num_rows = (int) $select_result->num_rows;
232
+                $num_rows = (int)$select_result->num_rows;
233 233
                 $this->_debug->logQuery($this->_sql_with_bound_parameters, $query_duration, $num_rows);
234 234
 
235 235
                 return new Result($this->_sql_with_bound_parameters, $select_result);
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     public function prepare($query): bool
289 289
     {
290 290
         if (!is_string($query)) {
291
-            throw new \InvalidArgumentException('$query was no string: ' . \gettype($query));
291
+            throw new \InvalidArgumentException('$query was no string: '.\gettype($query));
292 292
         }
293 293
 
294 294
         $this->_sql = $query;
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
         $bool = parent::prepare($query);
308 308
 
309 309
         if ($bool === false) {
310
-            $this->_debug->displayError('Can not prepare query: ' . $query . ' | ' . $this->error, false);
310
+            $this->_debug->displayError('Can not prepare query: '.$query.' | '.$this->error, false);
311 311
         }
312 312
 
313 313
         return $bool;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 // we need to replace the question mark "?" here
369 369
                 $values[1] = \str_replace('?', '###simple_mysqli__prepare_question_mark###', $values[1]);
370 370
                 // build the query (only for debugging)
371
-                $testQuery = (string) \preg_replace("/\?/", $values[1], $testQuery, 1);
371
+                $testQuery = (string)\preg_replace("/\?/", $values[1], $testQuery, 1);
372 372
             }
373 373
             $testQuery = \str_replace('###simple_mysqli__prepare_question_mark###', '?', $testQuery);
374 374
         }
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
 
400 400
             // exit if we have more then 3 "DB server has gone away"-errors
401 401
             if ($RECONNECT_COUNTER > 3) {
402
-                $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg . ":\n<br />" . $sql, 5);
402
+                $this->_debug->mailToAdmin('DB-Fatal-Error', $errorMsg.":\n<br />".$sql, 5);
403 403
 
404 404
                 throw new DBGoneAwayException($errorMsg);
405 405
             }
406 406
 
407
-            $this->_debug->mailToAdmin('DB-Error', $errorMsg . ":\n<br />" . $sql);
407
+            $this->_debug->mailToAdmin('DB-Error', $errorMsg.":\n<br />".$sql);
408 408
 
409 409
             // reconnect
410 410
             $RECONNECT_COUNTER++;
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
             return $this->execute();
415 415
         }
416 416
 
417
-        $this->_debug->mailToAdmin('SQL-Error', $errorMsg . ":\n<br />" . $sql);
417
+        $this->_debug->mailToAdmin('SQL-Error', $errorMsg.":\n<br />".$sql);
418 418
 
419 419
         // this query returned an error, we must display it (only for dev) !!!
420
-        $this->_debug->displayError($errorMsg . ' | ' . $sql);
420
+        $this->_debug->displayError($errorMsg.' | '.$sql);
421 421
 
422 422
         return false;
423 423
     }
Please login to merge, or discard this patch.