Completed
Push — develop ( 48041c...eb8457 )
by Agel_Nash
06:16
created
manager/includes/src/Database.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     }
45 45
 
46 46
     /**
47
-     * @param null $key
47
+     * @param string $key
48 48
      * @return mixed
49 49
      */
50 50
     public function getConfig($key = null)
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 
381 381
     /**
382 382
      * @param $fields
383
-     * @param $table
383
+     * @param string $table
384 384
      * @param string $where
385 385
      * @return bool|mixed|mysqli_result
386 386
      */
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
     }
526 526
 
527 527
     /**
528
-     * @param $name
528
+     * @param string $name
529 529
      * @param mysqli_result|string $dsq
530 530
      * @return array
531 531
      */
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
     }
667 667
 
668 668
     /**
669
-     * @param $tbl
669
+     * @param string $tbl
670 670
      * @return string
671 671
      */
672 672
     public function getFullTableName($tbl)
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
         $pre = null,
34 34
         $charset = '',
35 35
         $connection_method = 'SET CHARACTER SET'
36
-    ) {
36
+    ){
37 37
         $this->config['host'] = $host ? $host : $GLOBALS['database_server'];
38 38
         $this->config['dbase'] = $dbase ? $dbase : $GLOBALS['dbase'];
39 39
         $this->config['user'] = $uid ? $uid : $GLOBALS['database_user'];
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                         $ua = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_USER_AGENT']);
83 83
                         $referer = $modx->getPhpCompat()->htmlspecialchars($_SERVER['HTTP_REFERER']);
84 84
                         $modx->sendmail(array(
85
-                            'subject' => 'Missing to create the database connection! from ' . $modx->getPhpCompat()->entities($modx->config['site_name']),
85
+                            'subject' => 'Missing to create the database connection! from '.$modx->getPhpCompat()->entities($modx->config['site_name']),
86 86
                             'body'    => "{$logtitle}\n{$request_uri}\n{$ua}\n{$referer}",
87 87
                             'type'    => 'text'
88 88
                         ));
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
             $tend = $modx->getMicroTime();
98 98
             $totaltime = $tend - $tstart;
99 99
             if ($modx->dumpSQL) {
100
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>" . sprintf("Database connection was created in %2.4f s",
101
-                        $totaltime) . "</fieldset><br />";
100
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Database connection</legend>".sprintf("Database connection was created in %2.4f s",
101
+                        $totaltime)."</fieldset><br />";
102 102
             }
103 103
             $this->conn->set_charset($this->getConfig('charset'));
104 104
             $this->isConnected = true;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         if (1000 < $safeCount) {
132 132
             exit("Too many loops '{$safeCount}'");
133 133
         }
134
-        if ( ! ($this->conn instanceof mysqli)) {
134
+        if (!($this->conn instanceof mysqli)) {
135 135
             $this->connect();
136 136
         }
137 137
         if (is_array($s)) {
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
     public function query($sql, $watchError = true)
158 158
     {
159 159
         $modx = evolutionCMS();
160
-        if ( ! ($this->conn instanceof mysqli)) {
160
+        if (!($this->conn instanceof mysqli)) {
161 161
             $this->connect();
162 162
         }
163 163
         $tStart = $modx->getMicroTime();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                 case 1091:
178 178
                     break;
179 179
                 default:
180
-                    $modx->messageQuit('Execution of a query to the database failed - ' . $this->getLastError(), $sql);
180
+                    $modx->messageQuit('Execution of a query to the database failed - '.$this->getLastError(), $sql);
181 181
             }
182 182
         } else {
183 183
             $tend = $modx->getMicroTime();
@@ -191,24 +191,24 @@  discard block
 block discarded – undo
191 191
                     $debug_path[] = $line['function'];
192 192
                 }
193 193
                 $debug_path = implode(' > ', array_reverse($debug_path));
194
-                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query " . ($modx->executedQueries + 1) . " - " . sprintf("%2.2f ms",
195
-                        $totalTime * 1000) . "</legend>";
196
-                $modx->queryCode .= $sql . '<br><br>';
194
+                $modx->queryCode .= "<fieldset style='text-align:left'><legend>Query ".($modx->executedQueries + 1)." - ".sprintf("%2.2f ms",
195
+                        $totalTime * 1000)."</legend>";
196
+                $modx->queryCode .= $sql.'<br><br>';
197 197
                 if ($modx->event->name) {
198
-                    $modx->queryCode .= 'Current Event  => ' . $modx->event->name . '<br>';
198
+                    $modx->queryCode .= 'Current Event  => '.$modx->event->name.'<br>';
199 199
                 }
200 200
                 if ($modx->event->activePlugin) {
201
-                    $modx->queryCode .= 'Current Plugin => ' . $modx->event->activePlugin . '<br>';
201
+                    $modx->queryCode .= 'Current Plugin => '.$modx->event->activePlugin.'<br>';
202 202
                 }
203 203
                 if ($modx->currentSnippet) {
204
-                    $modx->queryCode .= 'Current Snippet => ' . $modx->currentSnippet . '<br>';
204
+                    $modx->queryCode .= 'Current Snippet => '.$modx->currentSnippet.'<br>';
205 205
                 }
206 206
                 if (stripos($sql, 'select') === 0) {
207
-                    $modx->queryCode .= 'Record Count => ' . $this->getRecordCount($result) . '<br>';
207
+                    $modx->queryCode .= 'Record Count => '.$this->getRecordCount($result).'<br>';
208 208
                 } else {
209
-                    $modx->queryCode .= 'Affected Rows => ' . $this->getAffectedRows() . '<br>';
209
+                    $modx->queryCode .= 'Affected Rows => '.$this->getAffectedRows().'<br>';
210 210
                 }
211
-                $modx->queryCode .= 'Functions Path => ' . $debug_path . '<br>';
211
+                $modx->queryCode .= 'Functions Path => '.$debug_path.'<br>';
212 212
                 $modx->queryCode .= "</fieldset><br />";
213 213
             }
214 214
             $modx->executedQueries++;
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
                     if ($value === null || strtolower($value) === 'null') {
316 316
                         $f = 'NULL';
317 317
                     } else {
318
-                        $f = "'" . $value . "'";
318
+                        $f = "'".$value."'";
319 319
                     }
320
-                    $fields[$key] = "`{$key}` = " . $f;
320
+                    $fields[$key] = "`{$key}` = ".$f;
321 321
                 }
322 322
                 $fields = implode(',', $fields);
323 323
             }
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
                 $this->query("INSERT INTO {$intotable} {$fields}");
353 353
             } else {
354 354
                 if (empty($fromtable)) {
355
-                    $fields = "(`" . implode("`, `", array_keys($fields)) . "`) VALUES('" . implode("', '",
356
-                            array_values($fields)) . "')";
355
+                    $fields = "(`".implode("`, `", array_keys($fields))."`) VALUES('".implode("', '",
356
+                            array_values($fields))."')";
357 357
                     $this->query("INSERT INTO {$intotable} {$fields}");
358 358
                 } else {
359 359
                     $fromtable = $this->replaceFullTableName($fromtable);
360
-                    $fields = "(" . implode(",", array_keys($fields)) . ")";
360
+                    $fields = "(".implode(",", array_keys($fields)).")";
361 361
                     $where = trim($where);
362 362
                     $limit = trim($limit);
363 363
                     if ($where !== '' && stripos($where, 'WHERE') !== 0) {
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
      */
452 452
     public function getInsertId($conn = null)
453 453
     {
454
-        if (! ($conn instanceof mysqli)) {
455
-            $conn =& $this->conn;
454
+        if (!($conn instanceof mysqli)) {
455
+            $conn = & $this->conn;
456 456
         }
457 457
 
458 458
         return $conn->insert_id;
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
      */
465 465
     public function getAffectedRows($conn = null)
466 466
     {
467
-        if (! ($conn instanceof mysqli)) {
468
-            $conn =& $this->conn;
467
+        if (!($conn instanceof mysqli)) {
468
+            $conn = & $this->conn;
469 469
         }
470 470
 
471 471
         return $conn->affected_rows;
@@ -477,8 +477,8 @@  discard block
 block discarded – undo
477 477
      */
478 478
     public function getLastError($conn = null)
479 479
     {
480
-        if (! ($conn instanceof mysqli)) {
481
-            $conn =& $this->conn;
480
+        if (!($conn instanceof mysqli)) {
481
+            $conn = & $this->conn;
482 482
         }
483 483
 
484 484
         return $conn->error;
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
     {
503 503
         $out = false;
504 504
         if ($ds instanceof mysqli_result) {
505
-            switch($mode){
505
+            switch ($mode) {
506 506
                 case 'assoc':
507 507
                     $out = $ds->fetch_assoc();
508 508
                     break;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
     public function getColumn($name, $dsq)
533 533
     {
534 534
         $col = array();
535
-        if ( ! ($dsq instanceof mysqli_result)) {
535
+        if (!($dsq instanceof mysqli_result)) {
536 536
             $dsq = $this->query($dsq);
537 537
         }
538 538
         if ($dsq) {
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
     public function getColumnNames($dsq)
552 552
     {
553 553
         $names = array();
554
-        if ( ! ($dsq instanceof mysqli_result)) {
554
+        if (!($dsq instanceof mysqli_result)) {
555 555
             $dsq = $this->query($dsq);
556 556
         }
557 557
         if ($dsq) {
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
     public function getValue($dsq)
572 572
     {
573 573
         $out = false;
574
-        if ( ! ($dsq instanceof mysqli_result)) {
574
+        if (!($dsq instanceof mysqli_result)) {
575 575
             $dsq = $this->query($dsq);
576 576
         }
577 577
         if ($dsq) {
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
 
662 662
     public function getTableName($table, $escape = true)
663 663
     {
664
-        $out = $this->getConfig('table_prefix') . $table;
665
-        return $escape ? '`' . $out . '`' : $out;
664
+        $out = $this->getConfig('table_prefix').$table;
665
+        return $escape ? '`'.$out.'`' : $out;
666 666
     }
667 667
 
668 668
     /**
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
      */
672 672
     public function getFullTableName($tbl)
673 673
     {
674
-        return $this->getConfig('dbase') . "." . $this->getTableName($tbl);
674
+        return $this->getConfig('dbase').".".$this->getTableName($tbl);
675 675
     }
676 676
 
677 677
     /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
         $tableName = trim($tableName);
685 685
         $dbase = trim($this->getConfig('dbase'), '`');
686 686
         $prefix = $this->getConfig('table_prefix');
687
-        if ((bool)$force === true) {
687
+        if ((bool) $force === true) {
688 688
             $result = "`{$dbase}`.`{$prefix}{$tableName}`";
689 689
         } elseif (strpos($tableName, '[+prefix+]') !== false) {
690 690
             $result = preg_replace('@\[\+prefix\+\]([0-9a-zA-Z_]+)@', "`{$dbase}`.`{$prefix}$1`", $tableName);
Please login to merge, or discard this patch.