Passed
Push — master ( 947f8b...1ddeab )
by kill
03:02
created
core/Mysql.php 1 patch
Spacing   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -23,19 +23,19 @@  discard block
 block discarded – undo
23 23
      * Variable which holds an amount of returned rows during get/getOne/select queries
24 24
      * @var string
25 25
      */
26
-    public $count = 0;
26
+    public $count=0;
27 27
     /**
28 28
      * Variable which holds an amount of returned rows during get/getOne/select queries with withTotalCount()
29 29
      * @var string
30 30
      */
31
-    public $totalCount = 0;
31
+    public $totalCount=0;
32 32
     /**
33 33
      * Return type: 'array' to return results as array, 'object' as object
34 34
      * 'json' as json string
35 35
      * @var string
36 36
      */
37
-    public $returnType = 'array';
38
-    public $trace = array();
37
+    public $returnType='array';
38
+    public $trace=array();
39 39
     /**
40 40
      * Per page limit for pagination
41 41
      *
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @var int
50 50
      */
51
-    public $totalPages = 0;
51
+    public $totalPages=0;
52 52
     /**
53 53
      * MySQLi instance
54 54
      * @var mysqli
@@ -68,53 +68,53 @@  discard block
 block discarded – undo
68 68
      * The SQL query options required after SELECT, INSERT, UPDATE or DELETE
69 69
      * @var string
70 70
      */
71
-    protected $_queryOptions = array();
71
+    protected $_queryOptions=array();
72 72
     /**
73 73
      * An array that holds where joins
74 74
      * @var array
75 75
      */
76
-    protected $_join = array();
76
+    protected $_join=array();
77 77
     /**
78 78
      * An array that holds where conditions
79 79
      * @var array
80 80
      */
81
-    protected $_where = array();
81
+    protected $_where=array();
82 82
     /**
83 83
      * An array that holds where join ands
84 84
      *
85 85
      * @var array
86 86
      */
87
-    protected $_joinAnd = array();
87
+    protected $_joinAnd=array();
88 88
     /**
89 89
      * An array that holds having conditions
90 90
      * @var array
91 91
      */
92
-    protected $_having = array();
92
+    protected $_having=array();
93 93
     /**
94 94
      * Dynamic type list for order by condition value
95 95
      * @var array
96 96
      */
97
-    protected $_orderBy = array(); // Create the empty 0 index
97
+    protected $_orderBy=array(); // Create the empty 0 index
98 98
     /**
99 99
      * Dynamic type list for group by condition value
100 100
      * @var array
101 101
      */
102
-    protected $_groupBy = array();
102
+    protected $_groupBy=array();
103 103
     /**
104 104
      * Dynamic type list for tempromary locking tables.
105 105
      * @var array
106 106
      */
107
-    protected $_tableLocks = array();
107
+    protected $_tableLocks=array();
108 108
     /**
109 109
      * Variable which holds the current table lock method.
110 110
      * @var string
111 111
      */
112
-    protected $_tableLockMethod = "READ";
112
+    protected $_tableLockMethod="READ";
113 113
     /**
114 114
      * Dynamic array that holds a combination of where condition/table data value types and parameter references
115 115
      * @var array
116 116
      */
117
-    protected $_bindParams = array('');
117
+    protected $_bindParams=array('');
118 118
     /**
119 119
      * Variable which holds last statement error
120 120
      * @var string
@@ -139,39 +139,39 @@  discard block
 block discarded – undo
139 139
      * Is Subquery object
140 140
      * @var bool
141 141
      */
142
-    protected $isSubQuery = false;
142
+    protected $isSubQuery=false;
143 143
     /**
144 144
      * Name of the auto increment column
145 145
      * @var int
146 146
      */
147
-    protected $_lastInsertId = null;
147
+    protected $_lastInsertId=null;
148 148
     /**
149 149
      * Column names for update when using onDuplicate method
150 150
      * @var array
151 151
      */
152
-    protected $_updateColumns = null;
152
+    protected $_updateColumns=null;
153 153
     /**
154 154
      * Should join() results be nested by table
155 155
      * @var bool
156 156
      */
157
-    protected $_nestJoin = false;
157
+    protected $_nestJoin=false;
158 158
     /**
159 159
      * FOR UPDATE flag
160 160
      * @var bool
161 161
      */
162
-    protected $_forUpdate = false;
162
+    protected $_forUpdate=false;
163 163
 
164 164
     /**
165 165
      * LOCK IN SHARE MODE flag
166 166
      * @var bool
167 167
      */
168
-    protected $_lockInShareMode = false;
168
+    protected $_lockInShareMode=false;
169 169
 
170 170
     /**
171 171
      * Key field for Map()'ed result array
172 172
      * @var string
173 173
      */
174
-    protected $_mapKey = null;
174
+    protected $_mapKey=null;
175 175
 
176 176
     /**
177 177
      * Variables for query execution tracing
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
      * Table prefix
184 184
      * @var string
185 185
      */
186
-    private $prefix = '';
186
+    private $prefix='';
187 187
     /**
188 188
      * 字段列表
189 189
      * @var string
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      * 含有表前缀的表名
194 194
      * @var string
195 195
      */
196
-    private $tableName = '';
196
+    private $tableName='';
197 197
 
198 198
     /**
199 199
      * @param string $host
@@ -203,30 +203,30 @@  discard block
 block discarded – undo
203 203
      * @param int $port
204 204
      * @param string $charset
205 205
      */
206
-    public function __construct($host = null, $username = null, $password = null, $db = null, $port = null, $charset = 'utf8') {
207
-        $isSubQuery = false;
206
+    public function __construct($host=null, $username=null, $password=null, $db=null, $port=null, $charset='utf8') {
207
+        $isSubQuery=false;
208 208
 
209 209
         // if params were passed as array
210 210
         if (is_array($host)) {
211 211
             foreach ($host as $key => $val) {
212
-                $$key = $val;
212
+                $$key=$val;
213 213
             }
214 214
         }
215 215
         // if host were set as mysqli socket
216 216
         if (is_object($host)) {
217
-            $this->_mysqli = $host;
217
+            $this->_mysqli=$host;
218 218
         } else {
219
-            $this->host = $host;
219
+            $this->host=$host;
220 220
         }
221 221
 
222
-        $this->_username = $username;
223
-        $this->_password = $password;
224
-        $this->db = $db;
225
-        $this->port = $port;
226
-        $this->charset = $charset;
222
+        $this->_username=$username;
223
+        $this->_password=$password;
224
+        $this->db=$db;
225
+        $this->port=$port;
226
+        $this->charset=$charset;
227 227
 
228 228
         if ($isSubQuery) {
229
-            $this->isSubQuery = true;
229
+            $this->isSubQuery=true;
230 230
             return;
231 231
         }
232 232
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
             $this->setPrefix($prefix);
235 235
         }
236 236
 
237
-        self::$_instance = $this;
237
+        self::$_instance=$this;
238 238
     }
239 239
 
240 240
     /**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      *
258 258
      * @return MysqliDb
259 259
      */
260
-    public static function subQuery($subQueryAlias = "") {
260
+    public static function subQuery($subQueryAlias="") {
261 261
         return new self(array('host' => $subQueryAlias, 'isSubQuery' => true));
262 262
     }
263 263
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
         if (!$this->_mysqli)
272 272
             return;
273 273
         $this->_mysqli->close();
274
-        $this->_mysqli = null;
274
+        $this->_mysqli=null;
275 275
     }
276 276
 
277 277
     /**
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      * @return MysqliDb
281 281
      */
282 282
     public function jsonBuilder() {
283
-        $this->returnType = 'json';
283
+        $this->returnType='json';
284 284
         return $this;
285 285
     }
286 286
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
      * @return MysqliDb
291 291
      */
292 292
     public function objectBuilder() {
293
-        $this->returnType = 'object';
293
+        $this->returnType='object';
294 294
         return $this;
295 295
     }
296 296
 
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
      *
305 305
      * @return array|null Contains the returned row from the query.
306 306
      */
307
-    public function rawQueryOne($query, $bindParams = null) {
308
-        $res = $this->rawQuery($query, $bindParams);
307
+    public function rawQueryOne($query, $bindParams=null) {
308
+        $res=$this->rawQuery($query, $bindParams);
309 309
         if (is_array($res) && isset($res[0])) {
310 310
             return $res[0];
311 311
         }
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
      *
322 322
      * @return array Contains the returned rows from the query.
323 323
      */
324
-    public function rawQuery($query, $bindParams = null) {
325
-        $params = array(''); // Create the empty 0 index
326
-        $this->_query = $query;
327
-        $stmt = $this->_prepareQuery();
324
+    public function rawQuery($query, $bindParams=null) {
325
+        $params=array(''); // Create the empty 0 index
326
+        $this->_query=$query;
327
+        $stmt=$this->_prepareQuery();
328 328
 
329 329
         if (is_array($bindParams) === true) {
330 330
             foreach ($bindParams as $prop => $val) {
331
-                $params[0] .= $this->_determineType($val);
331
+                $params[0].=$this->_determineType($val);
332 332
                 array_push($params, $bindParams[$prop]);
333 333
             }
334 334
 
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
         }
337 337
 
338 338
         $stmt->execute();
339
-        $this->count = $stmt->affected_rows;
340
-        $this->_stmtError = $stmt->error;
341
-        $this->_stmtErrno = $stmt->errno;
342
-        $this->_lastQuery = $this->replacePlaceHolders($this->_query, $params);
343
-        $res = $this->_dynamicBindResults($stmt);
339
+        $this->count=$stmt->affected_rows;
340
+        $this->_stmtError=$stmt->error;
341
+        $this->_stmtErrno=$stmt->errno;
342
+        $this->_lastQuery=$this->replacePlaceHolders($this->_query, $params);
343
+        $res=$this->_dynamicBindResults($stmt);
344 344
         $this->reset();
345 345
 
346 346
         return $res;
@@ -353,15 +353,15 @@  discard block
 block discarded – undo
353 353
      * @return mysqli_stmt
354 354
      */
355 355
     protected function _prepareQuery() {
356
-        if (!$stmt = $this->mysqli()->prepare($this->_query)) {
357
-            $msg = $this->mysqli()->error . " query: " . $this->_query;
358
-            $num = $this->mysqli()->errno;
356
+        if (!$stmt=$this->mysqli()->prepare($this->_query)) {
357
+            $msg=$this->mysqli()->error." query: ".$this->_query;
358
+            $num=$this->mysqli()->errno;
359 359
             $this->reset();
360 360
             throw new Exception($msg, $num);
361 361
         }
362 362
 
363 363
         if ($this->traceEnabled) {
364
-            $this->traceStartQ = microtime(true);
364
+            $this->traceStartQ=microtime(true);
365 365
         }
366 366
 
367 367
         return $stmt;
@@ -394,10 +394,10 @@  discard block
 block discarded – undo
394 394
             throw new Exception('MySQL host is not set');
395 395
         }
396 396
 
397
-        $this->_mysqli = new mysqli($this->host, $this->_username, $this->_password, $this->db, $this->port);
397
+        $this->_mysqli=new mysqli($this->host, $this->_username, $this->_password, $this->db, $this->port);
398 398
 
399 399
         if ($this->_mysqli->connect_error) {
400
-            throw new Exception('Connect Error ' . $this->_mysqli->connect_errno . ': ' . $this->_mysqli->connect_error, $this->_mysqli->connect_errno);
400
+            throw new Exception('Connect Error '.$this->_mysqli->connect_errno.': '.$this->_mysqli->connect_error, $this->_mysqli->connect_errno);
401 401
         }
402 402
 
403 403
         if ($this->charset) {
@@ -412,26 +412,26 @@  discard block
 block discarded – undo
412 412
      */
413 413
     protected function reset() {
414 414
         if ($this->traceEnabled) {
415
-            $this->trace[] = array($this->_lastQuery, (microtime(true) - $this->traceStartQ), $this->_traceGetCaller());
415
+            $this->trace[]=array($this->_lastQuery, (microtime(true) - $this->traceStartQ), $this->_traceGetCaller());
416 416
         }
417 417
 
418
-        $this->_where = array();
419
-        $this->_having = array();
420
-        $this->_join = array();
421
-        $this->_joinAnd = array();
422
-        $this->_orderBy = array();
423
-        $this->_groupBy = array();
424
-        $this->_bindParams = array(''); // Create the empty 0 index
425
-        $this->_query = null;
426
-        $this->_queryOptions = array();
427
-        $this->returnType = 'array';
428
-        $this->_nestJoin = false;
429
-        $this->_forUpdate = false;
430
-        $this->_lockInShareMode = false;
431
-        $this->tableName = '';
432
-        $this->_lastInsertId = null;
433
-        $this->_updateColumns = null;
434
-        $this->_mapKey = null;
418
+        $this->_where=array();
419
+        $this->_having=array();
420
+        $this->_join=array();
421
+        $this->_joinAnd=array();
422
+        $this->_orderBy=array();
423
+        $this->_groupBy=array();
424
+        $this->_bindParams=array(''); // Create the empty 0 index
425
+        $this->_query=null;
426
+        $this->_queryOptions=array();
427
+        $this->returnType='array';
428
+        $this->_nestJoin=false;
429
+        $this->_forUpdate=false;
430
+        $this->_lockInShareMode=false;
431
+        $this->tableName='';
432
+        $this->_lastInsertId=null;
433
+        $this->_updateColumns=null;
434
+        $this->_mapKey=null;
435 435
     }
436 436
 
437 437
     /**
@@ -440,14 +440,14 @@  discard block
 block discarded – undo
440 440
      * @return string with information
441 441
      */
442 442
     private function _traceGetCaller() {
443
-        $dd = debug_backtrace();
444
-        $caller = next($dd);
443
+        $dd=debug_backtrace();
444
+        $caller=next($dd);
445 445
         while (isset($caller) && $caller["file"] == __FILE__) {
446
-            $caller = next($dd);
446
+            $caller=next($dd);
447 447
         }
448 448
 
449
-        return __CLASS__ . "->" . $caller["function"] . "() >>  file \"" .
450
-            str_replace($this->traceStripPrefix, '', $caller["file"]) . "\" line #" . $caller["line"] . " ";
449
+        return __CLASS__."->".$caller["function"]."() >>  file \"".
450
+            str_replace($this->traceStripPrefix, '', $caller["file"])."\" line #".$caller["line"]." ";
451 451
     }
452 452
 
453 453
     /**
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
         //https://github.com/facebook/hhvm/issues/5155
496 496
         //Referenced data array is required by mysqli since PHP 5.3+
497 497
         if (strnatcmp(phpversion(), '5.3') >= 0) {
498
-            $refs = array();
498
+            $refs=array();
499 499
             foreach ($arr as $key => $value) {
500
-                $refs[$key] = &$arr[$key];
500
+                $refs[$key]=&$arr[$key];
501 501
             }
502 502
             return $refs;
503 503
         }
@@ -513,25 +513,25 @@  discard block
 block discarded – undo
513 513
      * @return string
514 514
      */
515 515
     protected function replacePlaceHolders($str, $vals) {
516
-        $i = 1;
517
-        $newStr = "";
516
+        $i=1;
517
+        $newStr="";
518 518
 
519 519
         if (empty($vals)) {
520 520
             return $str;
521 521
         }
522 522
 
523
-        while ($pos = strpos($str, "?")) {
524
-            $val = $vals[$i++];
523
+        while ($pos=strpos($str, "?")) {
524
+            $val=$vals[$i++];
525 525
             if (is_object($val)) {
526
-                $val = '[object]';
526
+                $val='[object]';
527 527
             }
528 528
             if ($val === null) {
529
-                $val = 'NULL';
529
+                $val='NULL';
530 530
             }
531
-            $newStr .= substr($str, 0, $pos) . "'" . $val . "'";
532
-            $str = substr($str, $pos + 1);
531
+            $newStr.=substr($str, 0, $pos)."'".$val."'";
532
+            $str=substr($str, $pos + 1);
533 533
         }
534
-        $newStr .= $str;
534
+        $newStr.=$str;
535 535
         return $newStr;
536 536
     }
537 537
 
@@ -544,34 +544,34 @@  discard block
 block discarded – undo
544 544
      * @return array The results of the SQL fetch.
545 545
      */
546 546
     protected function _dynamicBindResults(\mysqli_stmt $stmt) {
547
-        $parameters = array();
548
-        $results = array();
547
+        $parameters=array();
548
+        $results=array();
549 549
         /**
550 550
          * @see http://php.net/manual/en/mysqli-result.fetch-fields.php
551 551
          */
552
-        $mysqlLongType = 252;
553
-        $shouldStoreResult = false;
552
+        $mysqlLongType=252;
553
+        $shouldStoreResult=false;
554 554
 
555
-        $meta = $stmt->result_metadata();
555
+        $meta=$stmt->result_metadata();
556 556
 
557 557
         // if $meta is false yet sqlstate is true, there's no sql error but the query is
558 558
         // most likely an update/insert/delete which doesn't produce any results
559 559
         if (!$meta && $stmt->sqlstate)
560 560
             return array();
561 561
 
562
-        $row = array();
563
-        while ($field = $meta->fetch_field()) {
562
+        $row=array();
563
+        while ($field=$meta->fetch_field()) {
564 564
             if ($field->type == $mysqlLongType) {
565
-                $shouldStoreResult = true;
565
+                $shouldStoreResult=true;
566 566
             }
567 567
 
568 568
             if ($this->_nestJoin && $field->table != $this->tableName) {
569
-                $field->table = substr($field->table, strlen($this->prefix));
570
-                $row[$field->table][$field->name] = null;
571
-                $parameters[] = &$row[$field->table][$field->name];
569
+                $field->table=substr($field->table, strlen($this->prefix));
570
+                $row[$field->table][$field->name]=null;
571
+                $parameters[]=&$row[$field->table][$field->name];
572 572
             } else {
573
-                $row[$field->name] = null;
574
-                $parameters[] = &$row[$field->name];
573
+                $row[$field->name]=null;
574
+                $parameters[]=&$row[$field->name];
575 575
             }
576 576
         }
577 577
 
@@ -584,37 +584,37 @@  discard block
 block discarded – undo
584 584
 
585 585
         call_user_func_array(array($stmt, 'bind_result'), $parameters);
586 586
 
587
-        $this->totalCount = 0;
588
-        $this->count = 0;
587
+        $this->totalCount=0;
588
+        $this->count=0;
589 589
 
590 590
         while ($stmt->fetch()) {
591 591
             if ($this->returnType == 'object') {
592
-                $result = new stdClass ();
592
+                $result=new stdClass();
593 593
                 foreach ($row as $key => $val) {
594 594
                     if (is_array($val)) {
595
-                        $result->$key = new stdClass ();
595
+                        $result->$key=new stdClass();
596 596
                         foreach ($val as $k => $v) {
597
-                            $result->$key->$k = $v;
597
+                            $result->$key->$k=$v;
598 598
                         }
599 599
                     } else {
600
-                        $result->$key = $val;
600
+                        $result->$key=$val;
601 601
                     }
602 602
                 }
603 603
             } else {
604
-                $result = array();
604
+                $result=array();
605 605
                 foreach ($row as $key => $val) {
606 606
                     if (is_array($val)) {
607 607
                         foreach ($val as $k => $v) {
608
-                            $result[$key][$k] = $v;
608
+                            $result[$key][$k]=$v;
609 609
                         }
610 610
                     } else {
611
-                        $result[$key] = $val;
611
+                        $result[$key]=$val;
612 612
                     }
613 613
                 }
614 614
             }
615 615
             $this->count++;
616 616
             if ($this->_mapKey) {
617
-                $results[$row[$this->_mapKey]] = count($row) > 2 ? $result : end($result);
617
+                $results[$row[$this->_mapKey]]=count($row) > 2 ? $result : end($result);
618 618
             } else {
619 619
                 array_push($results, $result);
620 620
             }
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
         }
633 633
 
634 634
         if (in_array('SQL_CALC_FOUND_ROWS', $this->_queryOptions)) {
635
-            $stmt = $this->mysqli()->query('SELECT FOUND_ROWS()');
636
-            $totalCount = $stmt->fetch_row();
637
-            $this->totalCount = $totalCount[0];
635
+            $stmt=$this->mysqli()->query('SELECT FOUND_ROWS()');
636
+            $totalCount=$stmt->fetch_row();
637
+            $this->totalCount=$totalCount[0];
638 638
         }
639 639
 
640 640
         if ($this->returnType == 'json') {
@@ -654,21 +654,21 @@  discard block
 block discarded – undo
654 654
      *
655 655
      * @return mixed Contains the returned rows from the query.
656 656
      */
657
-    public function rawQueryValue($query, $bindParams = null) {
658
-        $res = $this->rawQuery($query, $bindParams);
657
+    public function rawQueryValue($query, $bindParams=null) {
658
+        $res=$this->rawQuery($query, $bindParams);
659 659
         if (!$res) {
660 660
             return null;
661 661
         }
662 662
 
663
-        $limit = preg_match('/limit\s+1;?$/i', $query);
664
-        $key = key($res[0]);
663
+        $limit=preg_match('/limit\s+1;?$/i', $query);
664
+        $key=key($res[0]);
665 665
         if (isset($res[0][$key]) && $limit == true) {
666 666
             return $res[0][$key];
667 667
         }
668 668
 
669
-        $newRes = Array();
670
-        for ($i = 0; $i < $this->count; $i++) {
671
-            $newRes[] = $res[$i][$key];
669
+        $newRes=Array();
670
+        for ($i=0; $i < $this->count; $i++) {
671
+            $newRes[]=$res[$i][$key];
672 672
         }
673 673
         return $newRes;
674 674
     }
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
      *
682 682
      * @return array Contains the returned rows from the query.
683 683
      */
684
-    public function query($query, $numRows = null) {
685
-        $this->_query = $query;
686
-        $stmt = $this->_buildQuery($numRows);
684
+    public function query($query, $numRows=null) {
685
+        $this->_query=$query;
686
+        $stmt=$this->_buildQuery($numRows);
687 687
         $stmt->execute();
688
-        $this->_stmtError = $stmt->error;
689
-        $this->_stmtErrno = $stmt->errno;
690
-        $res = $this->_dynamicBindResults($stmt);
688
+        $this->_stmtError=$stmt->error;
689
+        $this->_stmtErrno=$stmt->errno;
690
+        $res=$this->_dynamicBindResults($stmt);
691 691
         $this->reset();
692 692
 
693 693
         return $res;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
      *
705 705
      * @return mysqli_stmt Returns the $stmt object.
706 706
      */
707
-    protected function _buildQuery($numRows = null, $tableData = null) {
707
+    protected function _buildQuery($numRows=null, $tableData=null) {
708 708
         // $this->_buildJoinOld();
709 709
         $this->_buildJoin();
710 710
         $this->_buildInsertQuery($tableData);
@@ -716,20 +716,20 @@  discard block
 block discarded – undo
716 716
         $this->_buildOnDuplicate($tableData);
717 717
 
718 718
         if ($this->_forUpdate) {
719
-            $this->_query .= ' FOR UPDATE';
719
+            $this->_query.=' FOR UPDATE';
720 720
         }
721 721
         if ($this->_lockInShareMode) {
722
-            $this->_query .= ' LOCK IN SHARE MODE';
722
+            $this->_query.=' LOCK IN SHARE MODE';
723 723
         }
724 724
 
725
-        $this->_lastQuery = $this->replacePlaceHolders($this->_query, $this->_bindParams);
725
+        $this->_lastQuery=$this->replacePlaceHolders($this->_query, $this->_bindParams);
726 726
 
727 727
         if ($this->isSubQuery) {
728 728
             return;
729 729
         }
730 730
 
731 731
         // Prepare query
732
-        $stmt = $this->_prepareQuery();
732
+        $stmt=$this->_prepareQuery();
733 733
 
734 734
         // Bind parameters to statement if any
735 735
         if (count($this->_bindParams) > 1) {
@@ -747,20 +747,20 @@  discard block
 block discarded – undo
747 747
             return;
748 748
 
749 749
         foreach ($this->_join as $data) {
750
-            list ($joinType, $joinTable, $joinCondition) = $data;
750
+            list ($joinType, $joinTable, $joinCondition)=$data;
751 751
 
752 752
             if (is_object($joinTable))
753
-                $joinStr = $this->_buildPair("", $joinTable);
753
+                $joinStr=$this->_buildPair("", $joinTable);
754 754
             else
755
-                $joinStr = $joinTable;
755
+                $joinStr=$joinTable;
756 756
 
757
-            $this->_query .= " " . $joinType . " JOIN " . $joinStr . " on " . $joinCondition;
757
+            $this->_query.=" ".$joinType." JOIN ".$joinStr." on ".$joinCondition;
758 758
 
759 759
             // Add join and query
760 760
             if (!empty($this->_joinAnd) && isset($this->_joinAnd[$joinStr])) {
761 761
                 foreach ($this->_joinAnd[$joinStr] as $join_and_cond) {
762
-                    list ($concat, $varName, $operator, $val) = $join_and_cond;
763
-                    $this->_query .= " " . $concat . " " . $varName;
762
+                    list ($concat, $varName, $operator, $val)=$join_and_cond;
763
+                    $this->_query.=" ".$concat." ".$varName;
764 764
                     $this->conditionToSql($operator, $val);
765 765
                 }
766 766
             }
@@ -780,13 +780,13 @@  discard block
 block discarded – undo
780 780
     protected function _buildPair($operator, $value) {
781 781
         if (!is_object($value)) {
782 782
             $this->_bindParam($value);
783
-            return ' ' . $operator . ' ? ';
783
+            return ' '.$operator.' ? ';
784 784
         }
785 785
 
786
-        $subQuery = $value->getSubQuery();
786
+        $subQuery=$value->getSubQuery();
787 787
         $this->_bindParams($subQuery['params']);
788 788
 
789
-        return " " . $operator . " (" . $subQuery['query'] . ") " . $subQuery['alias'];
789
+        return " ".$operator." (".$subQuery['query'].") ".$subQuery['alias'];
790 790
     }
791 791
 
792 792
     /**
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
      * @param string Variable value
796 796
      */
797 797
     protected function _bindParam($value) {
798
-        $this->_bindParams[0] .= $this->_determineType($value);
798
+        $this->_bindParams[0].=$this->_determineType($value);
799 799
         array_push($this->_bindParams, $value);
800 800
     }
801 801
 
@@ -819,33 +819,33 @@  discard block
 block discarded – undo
819 819
         switch (strtolower($operator)) {
820 820
             case 'not in':
821 821
             case 'in':
822
-                $comparison = ' ' . $operator . ' (';
822
+                $comparison=' '.$operator.' (';
823 823
                 if (is_object($val)) {
824
-                    $comparison .= $this->_buildPair("", $val);
824
+                    $comparison.=$this->_buildPair("", $val);
825 825
                 } else {
826 826
                     foreach ($val as $v) {
827
-                        $comparison .= ' ?,';
827
+                        $comparison.=' ?,';
828 828
                         $this->_bindParam($v);
829 829
                     }
830 830
                 }
831
-                $this->_query .= rtrim($comparison, ',') . ' ) ';
831
+                $this->_query.=rtrim($comparison, ',').' ) ';
832 832
                 break;
833 833
             case 'not between':
834 834
             case 'between':
835
-                $this->_query .= " $operator ? AND ? ";
835
+                $this->_query.=" $operator ? AND ? ";
836 836
                 $this->_bindParams($val);
837 837
                 break;
838 838
             case 'not exists':
839 839
             case 'exists':
840
-                $this->_query .= $operator . $this->_buildPair("", $val);
840
+                $this->_query.=$operator.$this->_buildPair("", $val);
841 841
                 break;
842 842
             default:
843 843
                 if (is_array($val))
844 844
                     $this->_bindParams($val);
845 845
                 else if ($val === null)
846
-                    $this->_query .= $operator . " NULL";
846
+                    $this->_query.=$operator." NULL";
847 847
                 else if ($val != 'DBNULL' || $val == '0')
848
-                    $this->_query .= $this->_buildPair($operator, $val);
848
+                    $this->_query.=$this->_buildPair($operator, $val);
849 849
         }
850 850
     }
851 851
 
@@ -859,20 +859,20 @@  discard block
 block discarded – undo
859 859
             return;
860 860
         }
861 861
 
862
-        $isInsert = preg_match('/^[INSERT|REPLACE]/', $this->_query);
863
-        $dataColumns = array_keys($tableData);
862
+        $isInsert=preg_match('/^[INSERT|REPLACE]/', $this->_query);
863
+        $dataColumns=array_keys($tableData);
864 864
         if ($isInsert) {
865 865
             if (isset ($dataColumns[0]))
866
-                $this->_query .= ' (`' . implode($dataColumns, '`, `') . '`) ';
867
-            $this->_query .= ' VALUES (';
866
+                $this->_query.=' (`'.implode($dataColumns, '`, `').'`) ';
867
+            $this->_query.=' VALUES (';
868 868
         } else {
869
-            $this->_query .= " SET ";
869
+            $this->_query.=" SET ";
870 870
         }
871 871
 
872 872
         $this->_buildDataPairs($tableData, $dataColumns, $isInsert);
873 873
 
874 874
         if ($isInsert) {
875
-            $this->_query .= ')';
875
+            $this->_query.=')';
876 876
         }
877 877
     }
878 878
 
@@ -887,54 +887,54 @@  discard block
 block discarded – undo
887 887
      */
888 888
     public function _buildDataPairs($tableData, $tableColumns, $isInsert) {
889 889
         foreach ($tableColumns as $column) {
890
-            $value = $tableData[$column];
890
+            $value=$tableData[$column];
891 891
 
892 892
             if (!$isInsert) {
893 893
                 if (strpos($column, '.') === false) {
894
-                    $this->_query .= "`" . $column . "` = ";
894
+                    $this->_query.="`".$column."` = ";
895 895
                 } else {
896
-                    $this->_query .= str_replace('.', '.`', $column) . "` = ";
896
+                    $this->_query.=str_replace('.', '.`', $column)."` = ";
897 897
                 }
898 898
             }
899 899
 
900 900
             // Subquery value
901 901
             if ($value instanceof MysqliDb) {
902
-                $this->_query .= $this->_buildPair("", $value) . ", ";
902
+                $this->_query.=$this->_buildPair("", $value).", ";
903 903
                 continue;
904 904
             }
905 905
 
906 906
             // Simple value
907 907
             if (!is_array($value)) {
908 908
                 $this->_bindParam($value);
909
-                $this->_query .= '?, ';
909
+                $this->_query.='?, ';
910 910
                 continue;
911 911
             }
912 912
 
913 913
             // Function value
914
-            $key = key($value);
915
-            $val = $value[$key];
914
+            $key=key($value);
915
+            $val=$value[$key];
916 916
             switch ($key) {
917 917
                 case '[I]':
918
-                    $this->_query .= $column . $val . ", ";
918
+                    $this->_query.=$column.$val.", ";
919 919
                     break;
920 920
                 case '[F]':
921
-                    $this->_query .= $val[0] . ", ";
921
+                    $this->_query.=$val[0].", ";
922 922
                     if (!empty($val[1])) {
923 923
                         $this->_bindParams($val[1]);
924 924
                     }
925 925
                     break;
926 926
                 case '[N]':
927 927
                     if ($val == null) {
928
-                        $this->_query .= "!" . $column . ", ";
928
+                        $this->_query.="!".$column.", ";
929 929
                     } else {
930
-                        $this->_query .= "!" . $val . ", ";
930
+                        $this->_query.="!".$val.", ";
931 931
                     }
932 932
                     break;
933 933
                 default:
934 934
                     throw new Exception("Wrong operation");
935 935
             }
936 936
         }
937
-        $this->_query = rtrim($this->_query, ', ');
937
+        $this->_query=rtrim($this->_query, ', ');
938 938
     }
939 939
 
940 940
     /**
@@ -949,42 +949,42 @@  discard block
 block discarded – undo
949 949
         }
950 950
 
951 951
         //Prepare the where portion of the query
952
-        $this->_query .= ' ' . $operator;
952
+        $this->_query.=' '.$operator;
953 953
 
954 954
         foreach ($conditions as $cond) {
955
-            list ($concat, $varName, $operator, $val) = $cond;
956
-            $this->_query .= " " . $concat . " " . $varName;
955
+            list ($concat, $varName, $operator, $val)=$cond;
956
+            $this->_query.=" ".$concat." ".$varName;
957 957
 
958 958
             switch (strtolower($operator)) {
959 959
                 case 'not in':
960 960
                 case 'in':
961
-                    $comparison = ' ' . $operator . ' (';
961
+                    $comparison=' '.$operator.' (';
962 962
                     if (is_object($val)) {
963
-                        $comparison .= $this->_buildPair("", $val);
963
+                        $comparison.=$this->_buildPair("", $val);
964 964
                     } else {
965 965
                         foreach ($val as $v) {
966
-                            $comparison .= ' ?,';
966
+                            $comparison.=' ?,';
967 967
                             $this->_bindParam($v);
968 968
                         }
969 969
                     }
970
-                    $this->_query .= rtrim($comparison, ',') . ' ) ';
970
+                    $this->_query.=rtrim($comparison, ',').' ) ';
971 971
                     break;
972 972
                 case 'not between':
973 973
                 case 'between':
974
-                    $this->_query .= " $operator ? AND ? ";
974
+                    $this->_query.=" $operator ? AND ? ";
975 975
                     $this->_bindParams($val);
976 976
                     break;
977 977
                 case 'not exists':
978 978
                 case 'exists':
979
-                    $this->_query .= $operator . $this->_buildPair("", $val);
979
+                    $this->_query.=$operator.$this->_buildPair("", $val);
980 980
                     break;
981 981
                 default:
982 982
                     if (is_array($val)) {
983 983
                         $this->_bindParams($val);
984 984
                     } elseif ($val === null) {
985
-                        $this->_query .= ' ' . $operator . " NULL";
985
+                        $this->_query.=' '.$operator." NULL";
986 986
                     } elseif ($val != 'DBNULL' || $val == '0') {
987
-                        $this->_query .= $this->_buildPair($operator, $val);
987
+                        $this->_query.=$this->_buildPair($operator, $val);
988 988
                     }
989 989
             }
990 990
         }
@@ -1000,13 +1000,13 @@  discard block
 block discarded – undo
1000 1000
             return;
1001 1001
         }
1002 1002
 
1003
-        $this->_query .= " GROUP BY ";
1003
+        $this->_query.=" GROUP BY ";
1004 1004
 
1005 1005
         foreach ($this->_groupBy as $key => $value) {
1006
-            $this->_query .= $value . ", ";
1006
+            $this->_query.=$value.", ";
1007 1007
         }
1008 1008
 
1009
-        $this->_query = rtrim($this->_query, ', ') . " ";
1009
+        $this->_query=rtrim($this->_query, ', ')." ";
1010 1010
     }
1011 1011
 
1012 1012
     /**
@@ -1019,16 +1019,16 @@  discard block
 block discarded – undo
1019 1019
             return;
1020 1020
         }
1021 1021
 
1022
-        $this->_query .= " ORDER BY ";
1022
+        $this->_query.=" ORDER BY ";
1023 1023
         foreach ($this->_orderBy as $prop => $value) {
1024 1024
             if (strtolower(str_replace(" ", "", $prop)) == 'rand()') {
1025
-                $this->_query .= "rand(), ";
1025
+                $this->_query.="rand(), ";
1026 1026
             } else {
1027
-                $this->_query .= $prop . " " . $value . ", ";
1027
+                $this->_query.=$prop." ".$value.", ";
1028 1028
             }
1029 1029
         }
1030 1030
 
1031
-        $this->_query = rtrim($this->_query, ', ') . " ";
1031
+        $this->_query=rtrim($this->_query, ', ')." ";
1032 1032
     }
1033 1033
 
1034 1034
     /**
@@ -1045,9 +1045,9 @@  discard block
 block discarded – undo
1045 1045
         }
1046 1046
 
1047 1047
         if (is_array($numRows)) {
1048
-            $this->_query .= ' LIMIT ' . (int)$numRows[0] . ', ' . (int)$numRows[1];
1048
+            $this->_query.=' LIMIT '.(int) $numRows[0].', '.(int) $numRows[1];
1049 1049
         } else {
1050
-            $this->_query .= ' LIMIT ' . (int)$numRows;
1050
+            $this->_query.=' LIMIT '.(int) $numRows;
1051 1051
         }
1052 1052
     }
1053 1053
 
@@ -1058,18 +1058,18 @@  discard block
 block discarded – undo
1058 1058
      */
1059 1059
     protected function _buildOnDuplicate($tableData) {
1060 1060
         if (is_array($this->_updateColumns) && !empty($this->_updateColumns)) {
1061
-            $this->_query .= " ON DUPLICATE KEY UPDATE ";
1061
+            $this->_query.=" ON DUPLICATE KEY UPDATE ";
1062 1062
             if ($this->_lastInsertId) {
1063
-                $this->_query .= $this->_lastInsertId . "=LAST_INSERT_ID (" . $this->_lastInsertId . "), ";
1063
+                $this->_query.=$this->_lastInsertId."=LAST_INSERT_ID (".$this->_lastInsertId."), ";
1064 1064
             }
1065 1065
 
1066 1066
             foreach ($this->_updateColumns as $key => $val) {
1067 1067
                 // skip all params without a value
1068 1068
                 if (is_numeric($key)) {
1069
-                    $this->_updateColumns[$val] = '';
1069
+                    $this->_updateColumns[$val]='';
1070 1070
                     unset($this->_updateColumns[$key]);
1071 1071
                 } else {
1072
-                    $tableData[$key] = $val;
1072
+                    $tableData[$key]=$val;
1073 1073
                 }
1074 1074
             }
1075 1075
             $this->_buildDataPairs($tableData, array_keys($this->_updateColumns), false);
@@ -1085,10 +1085,10 @@  discard block
 block discarded – undo
1085 1085
      *
1086 1086
      * @return bool|array Boolean indicating the insertion failed (false), else return id-array ([int])
1087 1087
      */
1088
-    public function insertMulti($tableName, array $multiInsertData, array $dataKeys = null) {
1088
+    public function insertMulti($tableName, array $multiInsertData, array $dataKeys=null) {
1089 1089
         // only auto-commit our inserts, if no transaction is currently running
1090
-        $autoCommit = (isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true);
1091
-        $ids = array();
1090
+        $autoCommit=(isset($this->_transaction_in_progress) ? !$this->_transaction_in_progress : true);
1091
+        $ids=array();
1092 1092
 
1093 1093
         if ($autoCommit) {
1094 1094
             $this->startTransaction();
@@ -1097,17 +1097,17 @@  discard block
 block discarded – undo
1097 1097
         foreach ($multiInsertData as $insertData) {
1098 1098
             if ($dataKeys !== null) {
1099 1099
                 // apply column-names if given, else assume they're already given in the data
1100
-                $insertData = array_combine($dataKeys, $insertData);
1100
+                $insertData=array_combine($dataKeys, $insertData);
1101 1101
             }
1102 1102
 
1103
-            $id = $this->insert($tableName, $insertData);
1103
+            $id=$this->insert($tableName, $insertData);
1104 1104
             if (!$id) {
1105 1105
                 if ($autoCommit) {
1106 1106
                     $this->rollback();
1107 1107
                 }
1108 1108
                 return false;
1109 1109
             }
1110
-            $ids[] = $id;
1110
+            $ids[]=$id;
1111 1111
         }
1112 1112
 
1113 1113
         if ($autoCommit) {
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
      */
1126 1126
     public function startTransaction() {
1127 1127
         $this->mysqli()->autocommit(false);
1128
-        $this->_transaction_in_progress = true;
1128
+        $this->_transaction_in_progress=true;
1129 1129
         register_shutdown_function(array($this, "_transaction_status_check"));
1130 1130
     }
1131 1131
 
@@ -1155,14 +1155,14 @@  discard block
 block discarded – undo
1155 1155
             return;
1156 1156
         }
1157 1157
 
1158
-        $this->_query = $operation . " " . implode(' ', $this->_queryOptions) . " INTO " . $this->prefix . $tableName;
1159
-        $stmt = $this->_buildQuery(null, $insertData);
1160
-        $status = $stmt->execute();
1161
-        $this->_stmtError = $stmt->error;
1162
-        $this->_stmtErrno = $stmt->errno;
1163
-        $haveOnDuplicate = !empty ($this->_updateColumns);
1158
+        $this->_query=$operation." ".implode(' ', $this->_queryOptions)." INTO ".$this->prefix.$tableName;
1159
+        $stmt=$this->_buildQuery(null, $insertData);
1160
+        $status=$stmt->execute();
1161
+        $this->_stmtError=$stmt->error;
1162
+        $this->_stmtErrno=$stmt->errno;
1163
+        $haveOnDuplicate=!empty ($this->_updateColumns);
1164 1164
         $this->reset();
1165
-        $this->count = $stmt->affected_rows;
1165
+        $this->count=$stmt->affected_rows;
1166 1166
 
1167 1167
         if ($stmt->affected_rows < 1) {
1168 1168
             // in case of onDuplicate() usage, if no rows were inserted
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
      * @uses mysqli->autocommit(true);
1187 1187
      */
1188 1188
     public function rollback() {
1189
-        $result = $this->mysqli()->rollback();
1190
-        $this->_transaction_in_progress = false;
1189
+        $result=$this->mysqli()->rollback();
1190
+        $this->_transaction_in_progress=false;
1191 1191
         $this->mysqli()->autocommit(true);
1192 1192
         return $result;
1193 1193
     }
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
      * @uses mysqli->autocommit(true);
1200 1200
      */
1201 1201
     public function commit() {
1202
-        $result = $this->mysqli()->commit();
1203
-        $this->_transaction_in_progress = false;
1202
+        $result=$this->mysqli()->commit();
1203
+        $this->_transaction_in_progress=false;
1204 1204
         $this->mysqli()->autocommit(true);
1205 1205
         return $result;
1206 1206
     }
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
      *
1227 1227
      * @return array Contains the returned rows from the select query.
1228 1228
      */
1229
-    public function getOne($tableName, $columns = '*') {
1230
-        $res = $this->get($tableName, 1, $columns);
1229
+    public function getOne($tableName, $columns='*') {
1230
+        $res=$this->get($tableName, 1, $columns);
1231 1231
 
1232 1232
         if ($res instanceof MysqliDb) {
1233 1233
             return $res;
@@ -1250,31 +1250,31 @@  discard block
 block discarded – undo
1250 1250
      *
1251 1251
      * @return array Contains the returned rows from the select query.
1252 1252
      */
1253
-    public function get($tableName, $numRows = null, $columns = '*') {
1253
+    public function get($tableName, $numRows=null, $columns='*') {
1254 1254
         if (empty($columns)) {
1255
-            $columns = '*';
1255
+            $columns='*';
1256 1256
         }
1257 1257
 
1258
-        $column = is_array($columns) ? implode(', ', $columns) : $columns;
1258
+        $column=is_array($columns) ? implode(', ', $columns) : $columns;
1259 1259
 
1260 1260
         if (strpos($tableName, '.') === false) {
1261
-            $this->tableName = $this->prefix . $tableName;
1261
+            $this->tableName=$this->prefix.$tableName;
1262 1262
         } else {
1263
-            $this->tableName = $tableName;
1263
+            $this->tableName=$tableName;
1264 1264
         }
1265 1265
 
1266
-        $this->_query = 'SELECT ' . implode(' ', $this->_queryOptions) . ' ' .
1267
-            $column . " FROM " . $this->tableName;
1268
-        $stmt = $this->_buildQuery($numRows);
1266
+        $this->_query='SELECT '.implode(' ', $this->_queryOptions).' '.
1267
+            $column." FROM ".$this->tableName;
1268
+        $stmt=$this->_buildQuery($numRows);
1269 1269
 
1270 1270
         if ($this->isSubQuery) {
1271 1271
             return $this;
1272 1272
         }
1273 1273
 
1274 1274
         $stmt->execute();
1275
-        $this->_stmtError = $stmt->error;
1276
-        $this->_stmtErrno = $stmt->errno;
1277
-        $res = $this->_dynamicBindResults($stmt);
1275
+        $this->_stmtError=$stmt->error;
1276
+        $this->_stmtErrno=$stmt->errno;
1277
+        $res=$this->_dynamicBindResults($stmt);
1278 1278
         $this->reset();
1279 1279
 
1280 1280
         return $res;
@@ -1288,19 +1288,19 @@  discard block
 block discarded – undo
1288 1288
      *
1289 1289
      * @return bool
1290 1290
      */
1291
-    public function update($tableData, $numRows = null) {
1291
+    public function update($tableData, $numRows=null) {
1292 1292
         if ($this->isSubQuery) {
1293 1293
             return;
1294 1294
         }
1295 1295
 
1296
-        $this->_query = "UPDATE " . $this->tableName;
1296
+        $this->_query="UPDATE ".$this->tableName;
1297 1297
 
1298
-        $stmt = $this->_buildQuery($numRows, $tableData);
1299
-        $status = $stmt->execute();
1298
+        $stmt=$this->_buildQuery($numRows, $tableData);
1299
+        $status=$stmt->execute();
1300 1300
         $this->reset();
1301
-        $this->_stmtError = $stmt->error;
1302
-        $this->_stmtErrno = $stmt->errno;
1303
-        $this->count = $stmt->affected_rows;
1301
+        $this->_stmtError=$stmt->error;
1302
+        $this->_stmtErrno=$stmt->errno;
1303
+        $this->count=$stmt->affected_rows;
1304 1304
 
1305 1305
         return $status;
1306 1306
     }
@@ -1313,26 +1313,26 @@  discard block
 block discarded – undo
1313 1313
      *
1314 1314
      * @return bool Indicates success. 0 or 1.
1315 1315
      */
1316
-    public function delete($numRows = null) {
1316
+    public function delete($numRows=null) {
1317 1317
         if ($this->isSubQuery) {
1318 1318
             return;
1319 1319
         }
1320 1320
 
1321
-        $table = $this->tableName;
1321
+        $table=$this->tableName;
1322 1322
 
1323 1323
         if (count($this->_join)) {
1324
-            $this->_query = "DELETE " . preg_replace('/.* (.*)/', '$1', $table) . " FROM " . $table;
1324
+            $this->_query="DELETE ".preg_replace('/.* (.*)/', '$1', $table)." FROM ".$table;
1325 1325
         } else {
1326
-            $this->_query = "DELETE FROM " . $table;
1326
+            $this->_query="DELETE FROM ".$table;
1327 1327
         }
1328 1328
 
1329
-        $stmt = $this->_buildQuery($numRows);
1329
+        $stmt=$this->_buildQuery($numRows);
1330 1330
         $stmt->execute();
1331
-        $this->_stmtError = $stmt->error;
1332
-        $this->_stmtErrno = $stmt->errno;
1331
+        $this->_stmtError=$stmt->error;
1332
+        $this->_stmtErrno=$stmt->errno;
1333 1333
         $this->reset();
1334 1334
 
1335
-        return ($stmt->affected_rows > -1);    //	affected_rows returns 0 if nothing matched where statement, or required updating, -1 if error
1335
+        return ($stmt->affected_rows > -1); //	affected_rows returns 0 if nothing matched where statement, or required updating, -1 if error
1336 1336
     }
1337 1337
 
1338 1338
     /**
@@ -1344,9 +1344,9 @@  discard block
 block discarded – undo
1344 1344
      *
1345 1345
      * @return MysqliDb
1346 1346
      */
1347
-    public function onDuplicate($updateColumns, $lastInsertId = null) {
1348
-        $this->_lastInsertId = $lastInsertId;
1349
-        $this->_updateColumns = $updateColumns;
1347
+    public function onDuplicate($updateColumns, $lastInsertId=null) {
1348
+        $this->_lastInsertId=$lastInsertId;
1349
+        $this->_updateColumns=$updateColumns;
1350 1350
         return $this;
1351 1351
     }
1352 1352
 
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
      *
1362 1362
      * @return MysqliDb
1363 1363
      */
1364
-    public function orWhere($whereProp, $whereValue = 'DBNULL', $operator = '=') {
1364
+    public function orWhere($whereProp, $whereValue='DBNULL', $operator='=') {
1365 1365
         return $this->where($whereProp, $whereValue, $operator, 'OR');
1366 1366
     }
1367 1367
 
@@ -1377,18 +1377,18 @@  discard block
 block discarded – undo
1377 1377
      *
1378 1378
      * @return MysqliDb
1379 1379
      */
1380
-    public function where($whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') {
1380
+    public function where($whereProp, $whereValue='DBNULL', $operator='=', $cond='AND') {
1381 1381
         // forkaround for an old operation api
1382
-        if (is_array($whereValue) && ($key = key($whereValue)) != "0") {
1383
-            $operator = $key;
1384
-            $whereValue = $whereValue[$key];
1382
+        if (is_array($whereValue) && ($key=key($whereValue)) != "0") {
1383
+            $operator=$key;
1384
+            $whereValue=$whereValue[$key];
1385 1385
         }
1386 1386
 
1387 1387
         if (count($this->_where) == 0) {
1388
-            $cond = '';
1388
+            $cond='';
1389 1389
         }
1390 1390
 
1391
-        $this->_where[] = array($cond, $whereProp, $operator, $whereValue);
1391
+        $this->_where[]=array($cond, $whereProp, $operator, $whereValue);
1392 1392
         return $this;
1393 1393
     }
1394 1394
 
@@ -1403,7 +1403,7 @@  discard block
 block discarded – undo
1403 1403
      *
1404 1404
      * @return MysqliDb
1405 1405
      */
1406
-    public function orHaving($havingProp, $havingValue = null, $operator = null) {
1406
+    public function orHaving($havingProp, $havingValue=null, $operator=null) {
1407 1407
         return $this->having($havingProp, $havingValue, $operator, 'OR');
1408 1408
     }
1409 1409
 
@@ -1419,18 +1419,18 @@  discard block
 block discarded – undo
1419 1419
      * @return MysqliDb
1420 1420
      */
1421 1421
 
1422
-    public function having($havingProp, $havingValue = 'DBNULL', $operator = '=', $cond = 'AND') {
1422
+    public function having($havingProp, $havingValue='DBNULL', $operator='=', $cond='AND') {
1423 1423
         // forkaround for an old operation api
1424
-        if (is_array($havingValue) && ($key = key($havingValue)) != "0") {
1425
-            $operator = $key;
1426
-            $havingValue = $havingValue[$key];
1424
+        if (is_array($havingValue) && ($key=key($havingValue)) != "0") {
1425
+            $operator=$key;
1426
+            $havingValue=$havingValue[$key];
1427 1427
         }
1428 1428
 
1429 1429
         if (count($this->_having) == 0) {
1430
-            $cond = '';
1430
+            $cond='';
1431 1431
         }
1432 1432
 
1433
-        $this->_having[] = array($cond, $havingProp, $operator, $havingValue);
1433
+        $this->_having[]=array($cond, $havingProp, $operator, $havingValue);
1434 1434
         return $this;
1435 1435
     }
1436 1436
 
@@ -1446,19 +1446,19 @@  discard block
 block discarded – undo
1446 1446
      * @throws Exception
1447 1447
      * @return MysqliDb
1448 1448
      */
1449
-    public function join($joinTable, $joinCondition, $joinType = '') {
1450
-        $allowedTypes = array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER');
1451
-        $joinType = strtoupper(trim($joinType));
1449
+    public function join($joinTable, $joinCondition, $joinType='') {
1450
+        $allowedTypes=array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER');
1451
+        $joinType=strtoupper(trim($joinType));
1452 1452
 
1453 1453
         if ($joinType && !in_array($joinType, $allowedTypes)) {
1454
-            throw new Exception('Wrong JOIN type: ' . $joinType);
1454
+            throw new Exception('Wrong JOIN type: '.$joinType);
1455 1455
         }
1456 1456
 
1457 1457
         if (!is_object($joinTable)) {
1458
-            $joinTable = $this->prefix . $joinTable;
1458
+            $joinTable=$this->prefix.$joinTable;
1459 1459
         }
1460 1460
 
1461
-        $this->_join[] = Array($joinType, $joinTable, $joinCondition);
1461
+        $this->_join[]=Array($joinType, $joinTable, $joinCondition);
1462 1462
 
1463 1463
         return $this;
1464 1464
     }
@@ -1472,55 +1472,55 @@  discard block
 block discarded – undo
1472 1472
      * @param string $importSettings An Array defining the import settings as described in the README.md
1473 1473
      * @return boolean
1474 1474
      */
1475
-    public function loadData($importTable, $importFile, $importSettings = null) {
1475
+    public function loadData($importTable, $importFile, $importSettings=null) {
1476 1476
         // We have to check if the file exists
1477 1477
         if (!file_exists($importFile)) {
1478 1478
             // Throw an exception
1479
-            throw new Exception("importCSV -> importFile " . $importFile . " does not exists!");
1479
+            throw new Exception("importCSV -> importFile ".$importFile." does not exists!");
1480 1480
             return;
1481 1481
         }
1482 1482
 
1483 1483
         // Define the default values
1484 1484
         // We will merge it later
1485
-        $settings = Array("fieldChar" => ';', "lineChar" => PHP_EOL, "linesToIgnore" => 1);
1485
+        $settings=Array("fieldChar" => ';', "lineChar" => PHP_EOL, "linesToIgnore" => 1);
1486 1486
 
1487 1487
         // Check the import settings
1488 1488
         if (gettype($importSettings) == "array") {
1489 1489
             // Merge the default array with the custom one
1490
-            $settings = array_merge($settings, $importSettings);
1490
+            $settings=array_merge($settings, $importSettings);
1491 1491
         }
1492 1492
 
1493 1493
         // Add the prefix to the import table
1494
-        $table = $this->prefix . $importTable;
1494
+        $table=$this->prefix.$importTable;
1495 1495
 
1496 1496
         // Add 1 more slash to every slash so maria will interpret it as a path
1497
-        $importFile = str_replace("\\", "\\\\", $importFile);
1497
+        $importFile=str_replace("\\", "\\\\", $importFile);
1498 1498
 
1499 1499
         // Build SQL Syntax
1500
-        $sqlSyntax = sprintf('LOAD DATA INFILE \'%s\' INTO TABLE %s',
1500
+        $sqlSyntax=sprintf('LOAD DATA INFILE \'%s\' INTO TABLE %s',
1501 1501
             $importFile, $table);
1502 1502
 
1503 1503
         // FIELDS
1504
-        $sqlSyntax .= sprintf(' FIELDS TERMINATED BY \'%s\'', $settings["fieldChar"]);
1504
+        $sqlSyntax.=sprintf(' FIELDS TERMINATED BY \'%s\'', $settings["fieldChar"]);
1505 1505
         if (isset($settings["fieldEnclosure"])) {
1506
-            $sqlSyntax .= sprintf(' ENCLOSED BY \'%s\'', $settings["fieldEnclosure"]);
1506
+            $sqlSyntax.=sprintf(' ENCLOSED BY \'%s\'', $settings["fieldEnclosure"]);
1507 1507
         }
1508 1508
 
1509 1509
         // LINES
1510
-        $sqlSyntax .= sprintf(' LINES TERMINATED BY \'%s\'', $settings["lineChar"]);
1510
+        $sqlSyntax.=sprintf(' LINES TERMINATED BY \'%s\'', $settings["lineChar"]);
1511 1511
         if (isset($settings["lineStarting"])) {
1512
-            $sqlSyntax .= sprintf(' STARTING BY \'%s\'', $settings["lineStarting"]);
1512
+            $sqlSyntax.=sprintf(' STARTING BY \'%s\'', $settings["lineStarting"]);
1513 1513
         }
1514 1514
 
1515 1515
         // IGNORE LINES
1516
-        $sqlSyntax .= sprintf(' IGNORE %d LINES', $settings["linesToIgnore"]);
1516
+        $sqlSyntax.=sprintf(' IGNORE %d LINES', $settings["linesToIgnore"]);
1517 1517
 
1518 1518
         // Exceute the query unprepared because LOAD DATA only works with unprepared statements.
1519
-        $result = $this->queryUnprepared($sqlSyntax);
1519
+        $result=$this->queryUnprepared($sqlSyntax);
1520 1520
 
1521 1521
         // Are there rows modified?
1522 1522
         // Let the user know if the import failed / succeeded
1523
-        return (bool)$result;
1523
+        return (bool) $result;
1524 1524
     }
1525 1525
 
1526 1526
     /**
@@ -1533,11 +1533,11 @@  discard block
 block discarded – undo
1533 1533
      */
1534 1534
     private function queryUnprepared($query) {
1535 1535
         // Execute query
1536
-        $stmt = $this->mysqli()->query($query);
1536
+        $stmt=$this->mysqli()->query($query);
1537 1537
 
1538 1538
         // Failed?
1539 1539
         if (!$stmt) {
1540
-            throw new Exception("Unprepared Query Failed, ERRNO: " . $this->mysqli()->errno . " (" . $this->mysqli()->error . ")", $this->mysqli()->errno);
1540
+            throw new Exception("Unprepared Query Failed, ERRNO: ".$this->mysqli()->errno." (".$this->mysqli()->error.")", $this->mysqli()->errno);
1541 1541
         };
1542 1542
 
1543 1543
         // return stmt for future use
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
      *
1556 1556
      * @return boolean Returns true if the import succeeded, false if it failed.
1557 1557
      */
1558
-    public function loadXml($importTable, $importFile, $importSettings = null) {
1558
+    public function loadXml($importTable, $importFile, $importSettings=null) {
1559 1559
         // We have to check if the file exists
1560 1560
         if (!file_exists($importFile)) {
1561 1561
             // Does not exists
@@ -1564,37 +1564,37 @@  discard block
 block discarded – undo
1564 1564
         }
1565 1565
 
1566 1566
         // Create default values
1567
-        $settings = Array("linesToIgnore" => 0);
1567
+        $settings=Array("linesToIgnore" => 0);
1568 1568
 
1569 1569
         // Check the import settings
1570 1570
         if (gettype($importSettings) == "array") {
1571
-            $settings = array_merge($settings, $importSettings);
1571
+            $settings=array_merge($settings, $importSettings);
1572 1572
         }
1573 1573
 
1574 1574
         // Add the prefix to the import table
1575
-        $table = $this->prefix . $importTable;
1575
+        $table=$this->prefix.$importTable;
1576 1576
 
1577 1577
         // Add 1 more slash to every slash so maria will interpret it as a path
1578
-        $importFile = str_replace("\\", "\\\\", $importFile);
1578
+        $importFile=str_replace("\\", "\\\\", $importFile);
1579 1579
 
1580 1580
         // Build SQL Syntax
1581
-        $sqlSyntax = sprintf('LOAD XML INFILE \'%s\' INTO TABLE %s',
1581
+        $sqlSyntax=sprintf('LOAD XML INFILE \'%s\' INTO TABLE %s',
1582 1582
             $importFile, $table);
1583 1583
 
1584 1584
         // FIELDS
1585 1585
         if (isset($settings["rowTag"])) {
1586
-            $sqlSyntax .= sprintf(' ROWS IDENTIFIED BY \'%s\'', $settings["rowTag"]);
1586
+            $sqlSyntax.=sprintf(' ROWS IDENTIFIED BY \'%s\'', $settings["rowTag"]);
1587 1587
         }
1588 1588
 
1589 1589
         // IGNORE LINES
1590
-        $sqlSyntax .= sprintf(' IGNORE %d LINES', $settings["linesToIgnore"]);
1590
+        $sqlSyntax.=sprintf(' IGNORE %d LINES', $settings["linesToIgnore"]);
1591 1591
 
1592 1592
         // Exceute the query unprepared because LOAD XML only works with unprepared statements.
1593
-        $result = $this->queryUnprepared($sqlSyntax);
1593
+        $result=$this->queryUnprepared($sqlSyntax);
1594 1594
 
1595 1595
         // Are there rows modified?
1596 1596
         // Let the user know if the import failed / succeeded
1597
-        return (bool)$result;
1597
+        return (bool) $result;
1598 1598
     }
1599 1599
 
1600 1600
     /**
@@ -1609,30 +1609,30 @@  discard block
 block discarded – undo
1609 1609
      * @throws Exception
1610 1610
      * @return MysqliDb
1611 1611
      */
1612
-    public function orderBy($orderByField, $orderbyDirection = "DESC", $customFields = null) {
1613
-        $allowedDirection = Array("ASC", "DESC");
1614
-        $orderbyDirection = strtoupper(trim($orderbyDirection));
1615
-        $orderByField = preg_replace("/[^-a-z0-9\.\(\),_`\*\'\"]+/i", '', $orderByField);
1612
+    public function orderBy($orderByField, $orderbyDirection="DESC", $customFields=null) {
1613
+        $allowedDirection=Array("ASC", "DESC");
1614
+        $orderbyDirection=strtoupper(trim($orderbyDirection));
1615
+        $orderByField=preg_replace("/[^-a-z0-9\.\(\),_`\*\'\"]+/i", '', $orderByField);
1616 1616
 
1617 1617
         // Add table prefix to orderByField if needed.
1618 1618
         //FIXME: We are adding prefix only if table is enclosed into `` to distinguish aliases
1619 1619
         // from table names
1620
-        $orderByField = preg_replace('/(\`)([`a-zA-Z0-9_]*\.)/', '\1' . $this->prefix . '\2', $orderByField);
1620
+        $orderByField=preg_replace('/(\`)([`a-zA-Z0-9_]*\.)/', '\1'.$this->prefix.'\2', $orderByField);
1621 1621
 
1622 1622
 
1623 1623
         if (empty($orderbyDirection) || !in_array($orderbyDirection, $allowedDirection)) {
1624
-            throw new Exception('Wrong order direction: ' . $orderbyDirection);
1624
+            throw new Exception('Wrong order direction: '.$orderbyDirection);
1625 1625
         }
1626 1626
 
1627 1627
         if (is_array($customFields)) {
1628 1628
             foreach ($customFields as $key => $value) {
1629
-                $customFields[$key] = preg_replace("/[^-a-z0-9\.\(\),_` ]+/i", '', $value);
1629
+                $customFields[$key]=preg_replace("/[^-a-z0-9\.\(\),_` ]+/i", '', $value);
1630 1630
             }
1631 1631
 
1632
-            $orderByField = 'FIELD (' . $orderByField . ', "' . implode('","', $customFields) . '")';
1632
+            $orderByField='FIELD ('.$orderByField.', "'.implode('","', $customFields).'")';
1633 1633
         }
1634 1634
 
1635
-        $this->_orderBy[$orderByField] = $orderbyDirection;
1635
+        $this->_orderBy[$orderByField]=$orderbyDirection;
1636 1636
         return $this;
1637 1637
     }
1638 1638
 
@@ -1646,9 +1646,9 @@  discard block
 block discarded – undo
1646 1646
      * @return MysqliDb
1647 1647
      */
1648 1648
     public function groupBy($groupByField) {
1649
-        $groupByField = preg_replace("/[^-a-z0-9\.\(\),_\*]+/i", '', $groupByField);
1649
+        $groupByField=preg_replace("/[^-a-z0-9\.\(\),_\*]+/i", '', $groupByField);
1650 1650
 
1651
-        $this->_groupBy[] = $groupByField;
1651
+        $this->_groupBy[]=$groupByField;
1652 1652
         return $this;
1653 1653
     }
1654 1654
 
@@ -1667,7 +1667,7 @@  discard block
 block discarded – undo
1667 1667
             // Is it READ or WRITE?
1668 1668
             case "READ" || "WRITE":
1669 1669
                 // Succeed
1670
-                $this->_tableLockMethod = $method;
1670
+                $this->_tableLockMethod=$method;
1671 1671
                 break;
1672 1672
             default:
1673 1673
                 // Else throw an exception
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
      */
1689 1689
     public function lock($table) {
1690 1690
         // Main Query
1691
-        $this->_query = "LOCK TABLES";
1691
+        $this->_query="LOCK TABLES";
1692 1692
 
1693 1693
         // Is the table an array?
1694 1694
         if (gettype($table) == "array") {
@@ -1696,22 +1696,22 @@  discard block
 block discarded – undo
1696 1696
             foreach ($table as $key => $value) {
1697 1697
                 if (gettype($value) == "string") {
1698 1698
                     if ($key > 0) {
1699
-                        $this->_query .= ",";
1699
+                        $this->_query.=",";
1700 1700
                     }
1701
-                    $this->_query .= " " . $this->prefix . $value . " " . $this->_tableLockMethod;
1701
+                    $this->_query.=" ".$this->prefix.$value." ".$this->_tableLockMethod;
1702 1702
                 }
1703 1703
             }
1704 1704
         } else {
1705 1705
             // Build the table prefix
1706
-            $table = $this->prefix . $table;
1706
+            $table=$this->prefix.$table;
1707 1707
 
1708 1708
             // Build the query
1709
-            $this->_query = "LOCK TABLES " . $table . " " . $this->_tableLockMethod;
1709
+            $this->_query="LOCK TABLES ".$table." ".$this->_tableLockMethod;
1710 1710
         }
1711 1711
 
1712 1712
         // Exceute the query unprepared because LOCK only works with unprepared statements.
1713
-        $result = $this->queryUnprepared($this->_query);
1714
-        $errno = $this->mysqli()->errno;
1713
+        $result=$this->queryUnprepared($this->_query);
1714
+        $errno=$this->mysqli()->errno;
1715 1715
 
1716 1716
         // Reset the query
1717 1717
         $this->reset();
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
             return true;
1724 1724
         } // Something went wrong
1725 1725
         else {
1726
-            throw new Exception("Locking of table " . $table . " failed", $errno);
1726
+            throw new Exception("Locking of table ".$table." failed", $errno);
1727 1727
         }
1728 1728
 
1729 1729
         // Return the success value
@@ -1739,11 +1739,11 @@  discard block
 block discarded – undo
1739 1739
      */
1740 1740
     public function unlock() {
1741 1741
         // Build the query
1742
-        $this->_query = "UNLOCK TABLES";
1742
+        $this->_query="UNLOCK TABLES";
1743 1743
 
1744 1744
         // Exceute the query unprepared because UNLOCK and LOCK only works with unprepared statements.
1745
-        $result = $this->queryUnprepared($this->_query);
1746
-        $errno = $this->mysqli()->errno;
1745
+        $result=$this->queryUnprepared($this->_query);
1746
+        $errno=$this->mysqli()->errno;
1747 1747
 
1748 1748
         // Reset the query
1749 1749
         $this->reset();
@@ -1808,8 +1808,8 @@  discard block
 block discarded – undo
1808 1808
      *
1809 1809
      * @return MysqliDb
1810 1810
      */
1811
-    public function setPrefix($prefix = '') {
1812
-        $this->prefix = $prefix;
1811
+    public function setPrefix($prefix='') {
1812
+        $this->prefix=$prefix;
1813 1813
         return $this;
1814 1814
     }
1815 1815
 
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
 
1826 1826
         if ($this->_mysqli) {
1827 1827
             $this->_mysqli->close();
1828
-            $this->_mysqli = null;
1828
+            $this->_mysqli=null;
1829 1829
         }
1830 1830
     }
1831 1831
 
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
         if (!$this->_mysqli) {
1848 1848
             return "mysqli is null";
1849 1849
         }
1850
-        return trim($this->_stmtError . " " . $this->mysqli()->error);
1850
+        return trim($this->_stmtError." ".$this->mysqli()->error);
1851 1851
     }
1852 1852
 
1853 1853
     /* Helper functions */
@@ -1872,7 +1872,7 @@  discard block
 block discarded – undo
1872 1872
         }
1873 1873
 
1874 1874
         array_shift($this->_bindParams);
1875
-        $val = Array('query' => $this->_query,
1875
+        $val=Array('query' => $this->_query,
1876 1876
             'params' => $this->_bindParams,
1877 1877
             'alias' => $this->host
1878 1878
         );
@@ -1891,7 +1891,7 @@  discard block
 block discarded – undo
1891 1891
      *
1892 1892
      * @return array
1893 1893
      */
1894
-    public function now($diff = null, $func = "NOW()") {
1894
+    public function now($diff=null, $func="NOW()") {
1895 1895
         return array("[F]" => Array($this->interval($diff, $func)));
1896 1896
     }
1897 1897
 
@@ -1906,30 +1906,30 @@  discard block
 block discarded – undo
1906 1906
      *
1907 1907
      * @return string
1908 1908
      */
1909
-    public function interval($diff, $func = "NOW()") {
1910
-        $types = Array("s" => "second", "m" => "minute", "h" => "hour", "d" => "day", "M" => "month", "Y" => "year");
1911
-        $incr = '+';
1912
-        $items = '';
1913
-        $type = 'd';
1909
+    public function interval($diff, $func="NOW()") {
1910
+        $types=Array("s" => "second", "m" => "minute", "h" => "hour", "d" => "day", "M" => "month", "Y" => "year");
1911
+        $incr='+';
1912
+        $items='';
1913
+        $type='d';
1914 1914
 
1915 1915
         if ($diff && preg_match('/([+-]?) ?([0-9]+) ?([a-zA-Z]?)/', $diff, $matches)) {
1916 1916
             if (!empty($matches[1])) {
1917
-                $incr = $matches[1];
1917
+                $incr=$matches[1];
1918 1918
             }
1919 1919
 
1920 1920
             if (!empty($matches[2])) {
1921
-                $items = $matches[2];
1921
+                $items=$matches[2];
1922 1922
             }
1923 1923
 
1924 1924
             if (!empty($matches[3])) {
1925
-                $type = $matches[3];
1925
+                $type=$matches[3];
1926 1926
             }
1927 1927
 
1928 1928
             if (!in_array($type, array_keys($types))) {
1929 1929
                 throw new Exception("invalid interval type in '{$diff}'");
1930 1930
             }
1931 1931
 
1932
-            $func .= " " . $incr . " interval " . $items . " " . $types[$type] . " ";
1932
+            $func.=" ".$incr." interval ".$items." ".$types[$type]." ";
1933 1933
         }
1934 1934
         return $func;
1935 1935
     }
@@ -1942,11 +1942,11 @@  discard block
 block discarded – undo
1942 1942
      * @throws Exception
1943 1943
      * @return array
1944 1944
      */
1945
-    public function inc($num = 1) {
1945
+    public function inc($num=1) {
1946 1946
         if (!is_numeric($num)) {
1947 1947
             throw new Exception('Argument supplied to inc must be a number');
1948 1948
         }
1949
-        return array("[I]" => "+" . $num);
1949
+        return array("[I]" => "+".$num);
1950 1950
     }
1951 1951
 
1952 1952
     /**
@@ -1956,11 +1956,11 @@  discard block
 block discarded – undo
1956 1956
      *
1957 1957
      * @return array
1958 1958
      */
1959
-    public function dec($num = 1) {
1959
+    public function dec($num=1) {
1960 1960
         if (!is_numeric($num)) {
1961 1961
             throw new Exception('Argument supplied to dec must be a number');
1962 1962
         }
1963
-        return array("[I]" => "-" . $num);
1963
+        return array("[I]" => "-".$num);
1964 1964
     }
1965 1965
 
1966 1966
     /**
@@ -1970,8 +1970,8 @@  discard block
 block discarded – undo
1970 1970
      *
1971 1971
      * @return array
1972 1972
      */
1973
-    public function not($col = null) {
1974
-        return array("[N]" => (string)$col);
1973
+    public function not($col=null) {
1974
+        return array("[N]" => (string) $col);
1975 1975
     }
1976 1976
 
1977 1977
     /**
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
      *
1983 1983
      * @return array
1984 1984
      */
1985
-    public function func($expr, $bindParams = null) {
1985
+    public function func($expr, $bindParams=null) {
1986 1986
         return array("[F]" => array($expr, $bindParams));
1987 1987
     }
1988 1988
 
@@ -1992,8 +1992,8 @@  discard block
 block discarded – undo
1992 1992
      * @return MysqliDb new mysqlidb object
1993 1993
      */
1994 1994
     public function copy() {
1995
-        $copy = unserialize(serialize($this));
1996
-        $copy->_mysqli = null;
1995
+        $copy=unserialize(serialize($this));
1996
+        $copy->_mysqli=null;
1997 1997
         return $copy;
1998 1998
     }
1999 1999
 
@@ -2018,9 +2018,9 @@  discard block
 block discarded – undo
2018 2018
      *
2019 2019
      * @return MysqliDb
2020 2020
      */
2021
-    public function setTrace($enabled, $stripPrefix = null) {
2022
-        $this->traceEnabled = $enabled;
2023
-        $this->traceStripPrefix = $stripPrefix;
2021
+    public function setTrace($enabled, $stripPrefix=null) {
2022
+        $this->traceEnabled=$enabled;
2023
+        $this->traceStripPrefix=$stripPrefix;
2024 2024
         return $this;
2025 2025
     }
2026 2026
 
@@ -2032,14 +2032,14 @@  discard block
 block discarded – undo
2032 2032
      * @return bool True if table exists
2033 2033
      */
2034 2034
     public function tableExists($tables) {
2035
-        $tables = !is_array($tables) ? Array($tables) : $tables;
2036
-        $count = count($tables);
2035
+        $tables=!is_array($tables) ? Array($tables) : $tables;
2036
+        $count=count($tables);
2037 2037
         if ($count == 0) {
2038 2038
             return false;
2039 2039
         }
2040 2040
 
2041 2041
         foreach ($tables as $i => $value)
2042
-            $tables[$i] = $this->prefix . $value;
2042
+            $tables[$i]=$this->prefix.$value;
2043 2043
         $this->where('table_schema', $this->db);
2044 2044
         $this->where('table_name', $tables, 'in');
2045 2045
         $this->get('information_schema.tables', $count);
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
      * @return MysqliDb
2057 2057
      */
2058 2058
     public function map($idField) {
2059
-        $this->_mapKey = $idField;
2059
+        $this->_mapKey=$idField;
2060 2060
         return $this;
2061 2061
     }
2062 2062
 
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
      *
2072 2072
      * @return dbWrapper
2073 2073
      */
2074
-    public function joinOrWhere($whereJoin, $whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') {
2074
+    public function joinOrWhere($whereJoin, $whereProp, $whereValue='DBNULL', $operator='=', $cond='AND') {
2075 2075
         return $this->joinWhere($whereJoin, $whereProp, $whereValue, $operator, 'OR');
2076 2076
     }
2077 2077
 
@@ -2086,8 +2086,8 @@  discard block
 block discarded – undo
2086 2086
      *
2087 2087
      * @return dbWrapper
2088 2088
      */
2089
-    public function joinWhere($whereJoin, $whereProp, $whereValue = 'DBNULL', $operator = '=', $cond = 'AND') {
2090
-        $this->_joinAnd[$whereJoin][] = Array($cond, $whereProp, $operator, $whereValue);
2089
+    public function joinWhere($whereJoin, $whereProp, $whereValue='DBNULL', $operator='=', $cond='AND') {
2090
+        $this->_joinAnd[$whereJoin][]=Array($cond, $whereProp, $operator, $whereValue);
2091 2091
         return $this;
2092 2092
     }
2093 2093
 
@@ -2097,7 +2097,7 @@  discard block
 block discarded – undo
2097 2097
      * @return $this
2098 2098
      */
2099 2099
     public function table($table) {
2100
-        $this->tableName = $table;
2100
+        $this->tableName=$table;
2101 2101
         return $this;
2102 2102
     }
2103 2103
 
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
      * @return $this
2108 2108
      */
2109 2109
     public function name($name) {
2110
-        $this->tableName = $this->prefix . $name;
2110
+        $this->tableName=$this->prefix.$name;
2111 2111
         return $this;
2112 2112
     }
2113 2113
 
@@ -2121,8 +2121,8 @@  discard block
 block discarded – undo
2121 2121
      * @param null $default 默认值
2122 2122
      * @return mixed|null
2123 2123
      */
2124
-    public function value($col, $default = null) {
2125
-        $result = $this->getValue($this->tableName, $col);
2124
+    public function value($col, $default=null) {
2125
+        $result=$this->getValue($this->tableName, $col);
2126 2126
         return false !== $result ? $result : $default;
2127 2127
     }
2128 2128
 
@@ -2135,8 +2135,8 @@  discard block
 block discarded – undo
2135 2135
      *
2136 2136
      * @return mixed Contains the value of a returned column / array of values
2137 2137
      */
2138
-    public function getValue($tableName, $column, $limit = 1) {
2139
-        $res = $this->ArrayBuilder()->get($tableName, $limit, "{$column} AS retval");
2138
+    public function getValue($tableName, $column, $limit=1) {
2139
+        $res=$this->ArrayBuilder()->get($tableName, $limit, "{$column} AS retval");
2140 2140
 
2141 2141
         if (!$res) {
2142 2142
             return null;
@@ -2149,9 +2149,9 @@  discard block
 block discarded – undo
2149 2149
             return null;
2150 2150
         }
2151 2151
 
2152
-        $newRes = Array();
2153
-        for ($i = 0; $i < $this->count; $i++) {
2154
-            $newRes[] = $res[$i]['retval'];
2152
+        $newRes=Array();
2153
+        for ($i=0; $i < $this->count; $i++) {
2154
+            $newRes[]=$res[$i]['retval'];
2155 2155
         }
2156 2156
         return $newRes;
2157 2157
     }
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
      * @return MysqliDb
2164 2164
      */
2165 2165
     public function arrayBuilder() {
2166
-        $this->returnType = 'array';
2166
+        $this->returnType='array';
2167 2167
         return $this;
2168 2168
     }
2169 2169
 
@@ -2179,12 +2179,12 @@  discard block
 block discarded – undo
2179 2179
         return $this->value("SUM($field)");
2180 2180
     }
2181 2181
 
2182
-    public function count($field = '*') {
2182
+    public function count($field='*') {
2183 2183
         return $this->value("COUNT($field)");
2184 2184
     }
2185 2185
 
2186 2186
     public function limit($limit) {
2187
-        $this->pageLimit = $limit;
2187
+        $this->pageLimit=$limit;
2188 2188
         return $this;
2189 2189
     }
2190 2190
 
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
     }
2198 2198
 
2199 2199
     public function field($field) {
2200
-        $this->field = $field;
2200
+        $this->field=$field;
2201 2201
         return $this;
2202 2202
     }
2203 2203
 
@@ -2216,9 +2216,9 @@  discard block
 block discarded – undo
2216 2216
         return $this->_buildInsert($this->tableName, $data, 'REPLACE');
2217 2217
     }
2218 2218
 
2219
-    public function page($page, $pageLimit = '10') {
2220
-        $this->pageLimit = $pageLimit;
2221
-        $info = $this->paginate($this->tableName, $page, $this->field);
2219
+    public function page($page, $pageLimit='10') {
2220
+        $this->pageLimit=$pageLimit;
2221
+        $info=$this->paginate($this->tableName, $page, $this->field);
2222 2222
         return $info;
2223 2223
     }
2224 2224
 
@@ -2231,10 +2231,10 @@  discard block
 block discarded – undo
2231 2231
      * @param array|string $fields Array or coma separated list of fields to fetch
2232 2232
      * @return array
2233 2233
      */
2234
-    public function paginate($table, $page, $fields = null) {
2235
-        $offset = $this->pageLimit * ($page - 1);
2236
-        $res = $this->withTotalCount()->get($table, Array($offset, $this->pageLimit), $fields);
2237
-        $this->totalPages = ceil($this->totalCount / $this->pageLimit);
2234
+    public function paginate($table, $page, $fields=null) {
2235
+        $offset=$this->pageLimit * ($page - 1);
2236
+        $res=$this->withTotalCount()->get($table, Array($offset, $this->pageLimit), $fields);
2237
+        $this->totalPages=ceil($this->totalCount / $this->pageLimit);
2238 2238
         return $res;
2239 2239
     }
2240 2240
 
@@ -2259,28 +2259,28 @@  discard block
 block discarded – undo
2259 2259
      * @return MysqliDb
2260 2260
      */
2261 2261
     public function setQueryOption($options) {
2262
-        $allowedOptions = Array('ALL', 'DISTINCT', 'DISTINCTROW', 'HIGH_PRIORITY', 'STRAIGHT_JOIN', 'SQL_SMALL_RESULT',
2262
+        $allowedOptions=Array('ALL', 'DISTINCT', 'DISTINCTROW', 'HIGH_PRIORITY', 'STRAIGHT_JOIN', 'SQL_SMALL_RESULT',
2263 2263
             'SQL_BIG_RESULT', 'SQL_BUFFER_RESULT', 'SQL_CACHE', 'SQL_NO_CACHE', 'SQL_CALC_FOUND_ROWS',
2264 2264
             'LOW_PRIORITY', 'IGNORE', 'QUICK', 'MYSQLI_NESTJOIN', 'FOR UPDATE', 'LOCK IN SHARE MODE');
2265 2265
 
2266 2266
         if (!is_array($options)) {
2267
-            $options = Array($options);
2267
+            $options=Array($options);
2268 2268
         }
2269 2269
 
2270 2270
         foreach ($options as $option) {
2271
-            $option = strtoupper($option);
2271
+            $option=strtoupper($option);
2272 2272
             if (!in_array($option, $allowedOptions)) {
2273
-                throw new Exception('Wrong query option: ' . $option);
2273
+                throw new Exception('Wrong query option: '.$option);
2274 2274
             }
2275 2275
 
2276 2276
             if ($option == 'MYSQLI_NESTJOIN') {
2277
-                $this->_nestJoin = true;
2277
+                $this->_nestJoin=true;
2278 2278
             } elseif ($option == 'FOR UPDATE') {
2279
-                $this->_forUpdate = true;
2279
+                $this->_forUpdate=true;
2280 2280
             } elseif ($option == 'LOCK IN SHARE MODE') {
2281
-                $this->_lockInShareMode = true;
2281
+                $this->_lockInShareMode=true;
2282 2282
             } else {
2283
-                $this->_queryOptions[] = $option;
2283
+                $this->_queryOptions[]=$option;
2284 2284
             }
2285 2285
         }
2286 2286
 
@@ -2298,15 +2298,15 @@  discard block
 block discarded – undo
2298 2298
         }
2299 2299
 
2300 2300
         foreach ($this->_join as $data) {
2301
-            list ($joinType, $joinTable, $joinCondition) = $data;
2301
+            list ($joinType, $joinTable, $joinCondition)=$data;
2302 2302
 
2303 2303
             if (is_object($joinTable)) {
2304
-                $joinStr = $this->_buildPair("", $joinTable);
2304
+                $joinStr=$this->_buildPair("", $joinTable);
2305 2305
             } else {
2306
-                $joinStr = $joinTable;
2306
+                $joinStr=$joinTable;
2307 2307
             }
2308 2308
 
2309
-            $this->_query .= " " . $joinType . " JOIN " . $joinStr .
2309
+            $this->_query.=" ".$joinType." JOIN ".$joinStr.
2310 2310
                 (false !== stripos($joinCondition, 'using') ? " " : " on ")
2311 2311
                 . $joinCondition;
2312 2312
         }
Please login to merge, or discard this patch.