Passed
Pull Request — 5.1 (#1973)
by
unknown
09:36
created
library/think/db/builder/Pgsql.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
         if (!empty($limit)) {
38 38
             $limit = explode(',', $limit);
39 39
             if (count($limit) > 1) {
40
-                $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' ';
40
+                $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' ';
41 41
             } else {
42
-                $limitStr .= ' LIMIT ' . $limit[0] . ' ';
42
+                $limitStr .= ' LIMIT '.$limit[0].' ';
43 43
             }
44 44
         }
45 45
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         if (strpos($key, '->') && false === strpos($key, '(')) {
68 68
             // JSON字段支持
69 69
             list($field, $name) = explode('->', $key);
70
-            $key                = $field . '->>\'' . $name . '\'';
70
+            $key                = $field.'->>\''.$name.'\'';
71 71
         } elseif (strpos($key, '.')) {
72 72
             list($table, $key) = explode('.', $key, 2);
73 73
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
         }
85 85
 
86 86
         if (isset($table)) {
87
-            $key = $table . '.' . $key;
87
+            $key = $table.'.'.$key;
88 88
         }
89 89
 
90 90
         return $key;
Please login to merge, or discard this patch.
library/think/db/Builder.php 1 patch
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
             if (false !== strpos($key, '->')) {
133 133
                 list($key, $name) = explode('->', $key);
134 134
                 $item             = $this->parseKey($query, $key);
135
-                $result[$item]    = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key, $val, $bind) . ')';
135
+                $result[$item]    = 'json_set('.$item.', \'$.'.$name.'\', '.$this->parseDataBind($query, $key, $val, $bind).')';
136 136
             } elseif ('*' == $options['field'] && false === strpos($key, '.') && !in_array($key, $fields, true)) {
137 137
                 if ($options['strict']) {
138
-                    throw new Exception('fields not exists:[' . $key . ']');
138
+                    throw new Exception('fields not exists:['.$key.']');
139 139
                 }
140 140
             } elseif (is_null($val)) {
141 141
                 $result[$item] = 'NULL';
142 142
             } elseif (is_array($val) && !empty($val)) {
143 143
                 switch (strtoupper($val[0])) {
144 144
                     case 'INC':
145
-                        $result[$item] = $item . ' + ' . floatval($val[1]);
145
+                        $result[$item] = $item.' + '.floatval($val[1]);
146 146
                         break;
147 147
                     case 'DEC':
148
-                        $result[$item] = $item . ' - ' . floatval($val[1]);
148
+                        $result[$item] = $item.' - '.floatval($val[1]);
149 149
                         break;
150 150
                     case 'EXP':
151
-                        throw new Exception('not support data:[' . $val[0] . ']');
151
+                        throw new Exception('not support data:['.$val[0].']');
152 152
                 }
153 153
             } elseif (is_scalar($val)) {
154 154
                 // 过滤非标量数据
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
         $name = $query->bind($data, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR);
178 178
 
179
-        return ':' . $name;
179
+        return ':'.$name;
180 180
     }
181 181
 
182 182
     /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 
210 210
             foreach ($fields as $key => $field) {
211 211
                 if (!is_numeric($key)) {
212
-                    $array[] = $this->parseKey($query, $key) . ' AS ' . $this->parseKey($query, $field, true);
212
+                    $array[] = $this->parseKey($query, $key).' AS '.$this->parseKey($query, $field, true);
213 213
                 } else {
214 214
                     $array[] = $this->parseKey($query, $field);
215 215
                 }
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
         foreach ((array) $tables as $key => $table) {
237 237
             if (!is_numeric($key)) {
238 238
                 $key    = $this->connection->parseSqlTable($key);
239
-                $item[] = $this->parseKey($query, $key) . ' ' . $this->parseKey($query, $table);
239
+                $item[] = $this->parseKey($query, $key).' '.$this->parseKey($query, $table);
240 240
             } else {
241 241
                 $table = $this->connection->parseSqlTable($table);
242 242
 
243 243
                 if (isset($options['alias'][$table])) {
244
-                    $item[] = $this->parseKey($query, $table) . ' ' . $this->parseKey($query, $options['alias'][$table]);
244
+                    $item[] = $this->parseKey($query, $table).' '.$this->parseKey($query, $options['alias'][$table]);
245 245
                 } else {
246 246
                     $item[] = $this->parseKey($query, $table);
247 247
                 }
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
             list($field, $condition) = $options['soft_delete'];
269 269
 
270 270
             $binds    = $this->connection->getFieldsBind($options['table']);
271
-            $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : '';
272
-            $whereStr = $whereStr . $this->parseWhereItem($query, $field, $condition, '', $binds);
271
+            $whereStr = $whereStr ? '( '.$whereStr.' ) AND ' : '';
272
+            $whereStr = $whereStr.$this->parseWhereItem($query, $field, $condition, '', $binds);
273 273
         }
274 274
 
275
-        return empty($whereStr) ? '' : ' WHERE ' . $whereStr;
275
+        return empty($whereStr) ? '' : ' WHERE '.$whereStr;
276 276
     }
277 277
 
278 278
     /**
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
 
297 297
             foreach ($val as $value) {
298 298
                 if ($value instanceof Expression) {
299
-                    $str[] = ' ' . $logic . ' ( ' . $value->getValue() . ' )';
299
+                    $str[] = ' '.$logic.' ( '.$value->getValue().' )';
300 300
                     continue;
301 301
                 }
302 302
 
303 303
                 if (is_array($value)) {
304 304
                     if (key($value) !== 0) {
305
-                        throw new Exception('where express error:' . var_export($value, true));
305
+                        throw new Exception('where express error:'.var_export($value, true));
306 306
                     }
307 307
                     $field = array_shift($value);
308 308
                 } elseif (!($value instanceof \Closure)) {
309
-                    throw new Exception('where express error:' . var_export($value, true));
309
+                    throw new Exception('where express error:'.var_export($value, true));
310 310
                 }
311 311
 
312 312
                 if ($value instanceof \Closure) {
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
                     $whereClause = $this->buildWhere($query, $newQuery->getOptions('where'));
317 317
 
318 318
                     if (!empty($whereClause)) {
319
-                        $str[] = ' ' . $logic . ' ( ' . $whereClause . ' )';
319
+                        $str[] = ' '.$logic.' ( '.$whereClause.' )';
320 320
                     }
321 321
                 } elseif (is_array($field)) {
322 322
                     array_unshift($value, $field);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                         $str2[] = $this->parseWhereItem($query, array_shift($item), $item, $logic, $binds);
326 326
                     }
327 327
 
328
-                    $str[] = ' ' . $logic . ' ( ' . implode(' AND ', $str2) . ' )';
328
+                    $str[] = ' '.$logic.' ( '.implode(' AND ', $str2).' )';
329 329
                 } elseif (strpos($field, '|')) {
330 330
                     // 不同字段使用相同查询条件(OR)
331 331
                     $array = explode('|', $field);
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
                         $item[] = $this->parseWhereItem($query, $k, $value, '', $binds);
336 336
                     }
337 337
 
338
-                    $str[] = ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )';
338
+                    $str[] = ' '.$logic.' ( '.implode(' OR ', $item).' )';
339 339
                 } elseif (strpos($field, '&')) {
340 340
                     // 不同字段使用相同查询条件(AND)
341 341
                     $array = explode('&', $field);
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
                         $item[] = $this->parseWhereItem($query, $k, $value, '', $binds);
346 346
                     }
347 347
 
348
-                    $str[] = ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )';
348
+                    $str[] = ' '.$logic.' ( '.implode(' AND ', $item).' )';
349 349
                 } else {
350 350
                     // 对字段使用表达式查询
351 351
                     $field = is_string($field) ? $field : '';
352
-                    $str[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $logic, $binds);
352
+                    $str[] = ' '.$logic.' '.$this->parseWhereItem($query, $field, $value, $logic, $binds);
353 353
                 }
354 354
             }
355 355
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                 $str[] = $this->parseWhereItem($query, $field, $item, $rule, $binds);
388 388
             }
389 389
 
390
-            return '( ' . implode(' ' . $rule . ' ', $str) . ' )';
390
+            return '( '.implode(' '.$rule.' ', $str).' )';
391 391
         }
392 392
 
393 393
         // 检测操作符
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
             if (0 === strpos($value, ':') && $query->isBind(substr($value, 1))) {
415 415
             } else {
416 416
                 $name  = $query->bind($value, $bindType);
417
-                $value = ':' . $name;
417
+                $value = ':'.$name;
418 418
             }
419 419
         }
420 420
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
         }
428 428
 
429 429
         if (!isset($whereStr)) {
430
-            throw new Exception('where express error:' . $exp);
430
+            throw new Exception('where express error:'.$exp);
431 431
         }
432 432
 
433 433
         return $whereStr;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
         if (is_array($value)) {
452 452
             foreach ($value as $item) {
453 453
                 $name    = $query->bind($item, PDO::PARAM_STR);
454
-                $array[] = $key . ' ' . $exp . ' :' . $name;
454
+                $array[] = $key.' '.$exp.' :'.$name;
455 455
             }
456 456
 
457
-            $whereStr = '(' . implode(' ' . strtoupper($logic) . ' ', $array) . ')';
457
+            $whereStr = '('.implode(' '.strtoupper($logic).' ', $array).')';
458 458
         } else {
459
-            $whereStr = $key . ' ' . $exp . ' ' . $value;
459
+            $whereStr = $key.' '.$exp.' '.$value;
460 460
         }
461 461
 
462 462
         return $whereStr;
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
         list($op, $field2) = $value;
480 480
 
481 481
         if (!in_array($op, ['=', '<>', '>', '>=', '<', '<='])) {
482
-            throw new Exception('where express error:' . var_export($value, true));
482
+            throw new Exception('where express error:'.var_export($value, true));
483 483
         }
484 484
 
485
-        return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field2, true) . ' )';
485
+        return '( '.$key.' '.$op.' '.$this->parseKey($query, $field2, true).' )';
486 486
     }
487 487
 
488 488
     /**
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
     protected function parseExp(Query $query, $key, $exp, Expression $value, $field, $bindType)
500 500
     {
501 501
         // 表达式查询
502
-        return '( ' . $key . ' ' . $value->getValue() . ' )';
502
+        return '( '.$key.' '.$value->getValue().' )';
503 503
     }
504 504
 
505 505
     /**
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
     protected function parseNull(Query $query, $key, $exp, $value, $field, $bindType)
517 517
     {
518 518
         // NULL 查询
519
-        return $key . ' IS ' . $exp;
519
+        return $key.' IS '.$exp;
520 520
     }
521 521
 
522 522
     /**
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
         $min = $query->bind($data[0], $bindType);
539 539
         $max = $query->bind($data[1], $bindType);
540 540
 
541
-        return $key . ' ' . $exp . ' :' . $min . ' AND :' . $max . ' ';
541
+        return $key.' '.$exp.' :'.$min.' AND :'.$max.' ';
542 542
     }
543 543
 
544 544
     /**
@@ -560,10 +560,10 @@  discard block
 block discarded – undo
560 560
         } elseif ($value instanceof Expression) {
561 561
             $value = $value->getValue();
562 562
         } else {
563
-            throw new Exception('where express error:' . $value);
563
+            throw new Exception('where express error:'.$value);
564 564
         }
565 565
 
566
-        return $exp . ' (' . $value . ')';
566
+        return $exp.' ('.$value.')';
567 567
     }
568 568
 
569 569
     /**
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
      */
580 580
     protected function parseTime(Query $query, $key, $exp, $value, $field, $bindType)
581 581
     {
582
-        return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType);
582
+        return $key.' '.substr($exp, 0, 2).' '.$this->parseDateTime($query, $value, $field, $bindType);
583 583
     }
584 584
 
585 585
     /**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     protected function parseCompare(Query $query, $key, $exp, $value, $field, $bindType)
597 597
     {
598 598
         if (is_array($value)) {
599
-            throw new Exception('where express error:' . $exp . var_export($value, true));
599
+            throw new Exception('where express error:'.$exp.var_export($value, true));
600 600
         }
601 601
 
602 602
         // 比较运算
@@ -605,10 +605,10 @@  discard block
 block discarded – undo
605 605
         }
606 606
 
607 607
         if ('=' == $exp && is_null($value)) {
608
-            return $key . ' IS NULL';
608
+            return $key.' IS NULL';
609 609
         }
610 610
 
611
-        return $key . ' ' . $exp . ' ' . $value;
611
+        return $key.' '.$exp.' '.$value;
612 612
     }
613 613
 
614 614
     /**
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
             $value = explode(',', $value);
629 629
         }
630 630
 
631
-        return $key . ' ' . substr($exp, 0, -4)
631
+        return $key.' '.substr($exp, 0, -4)
632 632
         . $this->parseDateTime($query, $value[0], $field, $bindType)
633 633
         . ' AND '
634 634
         . $this->parseDateTime($query, $value[1], $field, $bindType);
@@ -659,18 +659,18 @@  discard block
 block discarded – undo
659 659
 
660 660
             foreach ($value as $k => $v) {
661 661
                 $name    = $query->bind($v, $bindType);
662
-                $array[] = ':' . $name;
662
+                $array[] = ':'.$name;
663 663
             }
664 664
 
665 665
             if (count($array) == 1) {
666
-                return $key . ('IN' == $exp ? ' = ' : ' <> ') . $array[0];
666
+                return $key.('IN' == $exp ? ' = ' : ' <> ').$array[0];
667 667
             } else {
668 668
                 $zone  = implode(',', $array);
669 669
                 $value = empty($zone) ? "''" : $zone;
670 670
             }
671 671
         }
672 672
 
673
-        return $key . ' ' . $exp . ' (' . $value . ')';
673
+        return $key.' '.$exp.' ('.$value.')';
674 674
     }
675 675
 
676 676
     /**
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 
736 736
         $name = $query->bind($value, $bindType);
737 737
 
738
-        return ':' . $name;
738
+        return ':'.$name;
739 739
     }
740 740
 
741 741
     /**
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
      */
748 748
     protected function parseLimit(Query $query, $limit)
749 749
     {
750
-        return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT ' . $limit . ' ' : '';
750
+        return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT '.$limit.' ' : '';
751 751
     }
752 752
 
753 753
     /**
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
                     } elseif (strpos($val, '=')) {
774 774
                         list($val1, $val2) = explode('=', $val, 2);
775 775
 
776
-                        $condition[] = $this->parseKey($query, $val1) . '=' . $this->parseKey($query, $val2);
776
+                        $condition[] = $this->parseKey($query, $val1).'='.$this->parseKey($query, $val2);
777 777
                     } else {
778 778
                         $condition[] = $val;
779 779
                     }
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
                 $table = $this->parseTable($query, $table);
783 783
 
784
-                $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . implode(' AND ', $condition);
784
+                $joinStr .= ' '.$type.' JOIN '.$table.' ON '.implode(' AND ', $condition);
785 785
             }
786 786
         }
787 787
 
@@ -806,22 +806,22 @@  discard block
 block discarded – undo
806 806
                 $array[] = $this->parseRand($query);
807 807
             } elseif (is_string($val)) {
808 808
                 if (is_numeric($key)) {
809
-                    list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' ');
809
+                    list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val.' ');
810 810
                 } else {
811 811
                     $sort = $val;
812 812
                 }
813 813
 
814 814
                 if (preg_match('/^[\w\.]+$/', $key)) {
815 815
                     $sort    = strtoupper($sort);
816
-                    $sort    = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
817
-                    $array[] = $this->parseKey($query, $key, true) . $sort;
816
+                    $sort    = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : '';
817
+                    $array[] = $this->parseKey($query, $key, true).$sort;
818 818
                 } else {
819
-                    throw new Exception('order express error:' . $key);
819
+                    throw new Exception('order express error:'.$key);
820 820
                 }
821 821
             }
822 822
         }
823 823
 
824
-        return empty($array) ? '' : ' ORDER BY ' . implode(',', $array);
824
+        return empty($array) ? '' : ' ORDER BY '.implode(',', $array);
825 825
     }
826 826
 
827 827
     /**
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
         }
843 843
 
844 844
         $sort = strtoupper($sort);
845
-        $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : '';
845
+        $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : '';
846 846
 
847 847
         $options = $query->getOptions();
848 848
         $bind    = $this->connection->getFieldsBind($options['table']);
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
             $val[$k] = $this->parseDataBind($query, $key, $item, $bind);
852 852
         }
853 853
 
854
-        return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort;
854
+        return 'field('.$this->parseKey($query, $key, true).','.implode(',', $val).')'.$sort;
855 855
     }
856 856
 
857 857
     /**
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
             $val[] = $this->parseKey($query, $key);
876 876
         }
877 877
 
878
-        return ' GROUP BY ' . implode(',', $val);
878
+        return ' GROUP BY '.implode(',', $val);
879 879
     }
880 880
 
881 881
     /**
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
      */
888 888
     protected function parseHaving(Query $query, $having)
889 889
     {
890
-        return !empty($having) ? ' HAVING ' . $having : '';
890
+        return !empty($having) ? ' HAVING '.$having : '';
891 891
     }
892 892
 
893 893
     /**
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
             $comment = strstr($comment, '*/', true);
904 904
         }
905 905
 
906
-        return !empty($comment) ? ' /* ' . $comment . ' */' : '';
906
+        return !empty($comment) ? ' /* '.$comment.' */' : '';
907 907
     }
908 908
 
909 909
     /**
@@ -936,13 +936,13 @@  discard block
 block discarded – undo
936 936
 
937 937
         foreach ($union as $u) {
938 938
             if ($u instanceof \Closure) {
939
-                $sql[] = $type . ' ' . $this->parseClosure($query, $u);
939
+                $sql[] = $type.' '.$this->parseClosure($query, $u);
940 940
             } elseif (is_string($u)) {
941
-                $sql[] = $type . ' ( ' . $this->connection->parseSqlTable($u) . ' )';
941
+                $sql[] = $type.' ( '.$this->connection->parseSqlTable($u).' )';
942 942
             }
943 943
         }
944 944
 
945
-        return ' ' . implode(' ', $sql);
945
+        return ' '.implode(' ', $sql);
946 946
     }
947 947
 
948 948
     /**
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
         if (is_bool($lock)) {
974 974
             return $lock ? ' FOR UPDATE ' : '';
975 975
         } elseif (is_string($lock) && !empty($lock)) {
976
-            return ' ' . trim($lock) . ' ';
976
+            return ' '.trim($lock).' ';
977 977
         }
978 978
     }
979 979
 
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
         foreach ($dataSet as $data) {
1065 1065
             $data = $this->parseData($query, $data, $allowFields, $bind);
1066 1066
 
1067
-            $values[] = 'SELECT ' . implode(',', array_values($data));
1067
+            $values[] = 'SELECT '.implode(',', array_values($data));
1068 1068
 
1069 1069
             if (!isset($insertFields)) {
1070 1070
                 $insertFields = array_keys($data);
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
             $field = $this->parseKey($query, $field, true);
1108 1108
         }
1109 1109
 
1110
-        return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query);
1110
+        return 'INSERT INTO '.$this->parseTable($query, $table).' ('.implode(',', $fields).') '.$this->select($query);
1111 1111
     }
1112 1112
 
1113 1113
     /**
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
         }
1128 1128
 
1129 1129
         foreach ($data as $key => $val) {
1130
-            $set[] = $key . ' = ' . $val;
1130
+            $set[] = $key.' = '.$val;
1131 1131
         }
1132 1132
 
1133 1133
         return str_replace(
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
             ['%TABLE%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'],
1160 1160
             [
1161 1161
                 $this->parseTable($query, $options['table']),
1162
-                !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '',
1162
+                !empty($options['using']) ? ' USING '.$this->parseTable($query, $options['using']).' ' : '',
1163 1163
                 $this->parseJoin($query, $options['join']),
1164 1164
                 $this->parseWhere($query, $options['where']),
1165 1165
                 $this->parseOrder($query, $options['order']),
Please login to merge, or discard this patch.
library/think/db/Connection.php 2 patches
Spacing   +24 added lines, -25 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             }
190 190
 
191 191
             // 记录初始化信息
192
-            Container::get('app')->log('[ DB ] INIT ' . $config['type']);
192
+            Container::get('app')->log('[ DB ] INIT '.$config['type']);
193 193
 
194 194
             if (true === $name) {
195 195
                 $name = md5(serialize($config));
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             return $this->builderClassName;
213 213
         }
214 214
 
215
-        return $this->getConfig('builder') ?: '\\think\\db\\builder\\' . ucfirst($this->getConfig('type'));
215
+        return $this->getConfig('builder') ?: '\\think\\db\\builder\\'.ucfirst($this->getConfig('type'));
216 216
     }
217 217
 
218 218
     /**
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
     public function parseSqlTable($sql)
327 327
     {
328 328
         if (false !== strpos($sql, '__')) {
329
-            $sql = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function ($match) {
330
-                return $this->getConfig('prefix') . strtolower($match[1]);
329
+            $sql = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) {
330
+                return $this->getConfig('prefix').strtolower($match[1]);
331 331
             }, $sql);
332 332
         }
333 333
 
@@ -362,14 +362,14 @@  discard block
 block discarded – undo
362 362
         list($tableName) = explode(' ', $tableName);
363 363
 
364 364
         if (false === strpos($tableName, '.')) {
365
-            $schema = $this->getConfig('database') . '.' . $tableName;
365
+            $schema = $this->getConfig('database').'.'.$tableName;
366 366
         } else {
367 367
             $schema = $tableName;
368 368
         }
369 369
 
370 370
         if (!isset(self::$info[$schema])) {
371 371
             // 读取缓存
372
-            $cacheFile = Container::get('app')->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR . $schema . '.php';
372
+            $cacheFile = Container::get('app')->getRuntimePath().'schema'.DIRECTORY_SEPARATOR.$schema.'.php';
373 373
 
374 374
             if (!$this->config['debug'] && is_file($cacheFile)) {
375 375
                 $info = include $cacheFile;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
             }
379 379
 
380 380
             $fields = array_keys($info);
381
-            $bind   = $type   = [];
381
+            $bind   = $type = [];
382 382
 
383 383
             foreach ($info as $key => $val) {
384 384
                 // 记录字段类型
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
             if ($config['debug']) {
531 531
                 // 记录数据库连接信息
532
-                $this->log('[ DB ] CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']);
532
+                $this->log('[ DB ] CONNECT:[ UseTime:'.number_format(microtime(true) - $startTime, 6).'s ] '.$config['dsn']);
533 533
             }
534 534
 
535 535
             return $this->links[$linkNum];
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
             list($distinct, $field) = explode(' ', $field);
1323 1323
         }
1324 1324
 
1325
-        $field = $aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $this->builder->parseKey($query, $field, true) . ') AS tp_' . strtolower($aggregate);
1325
+        $field = $aggregate.'('.(!empty($distinct) ? 'DISTINCT ' : '').$this->builder->parseKey($query, $field, true).') AS tp_'.strtolower($aggregate);
1326 1326
 
1327 1327
         return $this->value($query, $field, 0, false);
1328 1328
     }
@@ -1468,15 +1468,14 @@  discard block
 block discarded – undo
1468 1468
             $type  = is_array($val) ? $val[1] : PDO::PARAM_STR;
1469 1469
 
1470 1470
             if ((self::PARAM_FLOAT == $type || PDO::PARAM_STR == $type) && is_string($value)) {
1471
-                $value = '\'' . addslashes($value) . '\'';
1471
+                $value = '\''.addslashes($value).'\'';
1472 1472
             } elseif (PDO::PARAM_INT == $type && '' === $value) {
1473 1473
                 $value = 0;
1474 1474
             }
1475 1475
 
1476 1476
             // 判断占位符
1477 1477
             $sql = is_numeric($key) ?
1478
-            substr_replace($sql, $value, strpos($sql, '?'), 1) :
1479
-            substr_replace($sql, $value, strpos($sql, ':' . $key), strlen(':' . $key));
1478
+            substr_replace($sql, $value, strpos($sql, '?'), 1) : substr_replace($sql, $value, strpos($sql, ':'.$key), strlen(':'.$key));
1480 1479
         }
1481 1480
 
1482 1481
         return rtrim($sql);
@@ -1495,7 +1494,7 @@  discard block
 block discarded – undo
1495 1494
     {
1496 1495
         foreach ($bind as $key => $val) {
1497 1496
             // 占位符
1498
-            $param = is_int($key) ? $key + 1 : ':' . $key;
1497
+            $param = is_int($key) ? $key + 1 : ':'.$key;
1499 1498
 
1500 1499
             if (is_array($val)) {
1501 1500
                 if (PDO::PARAM_INT == $val[1] && '' === $val[0]) {
@@ -1531,7 +1530,7 @@  discard block
 block discarded – undo
1531 1530
     protected function bindParam($bind)
1532 1531
     {
1533 1532
         foreach ($bind as $key => $val) {
1534
-            $param = is_int($key) ? $key + 1 : ':' . $key;
1533
+            $param = is_int($key) ? $key + 1 : ':'.$key;
1535 1534
 
1536 1535
             if (is_array($val)) {
1537 1536
                 array_unshift($val, $param);
@@ -1687,7 +1686,7 @@  discard block
 block discarded – undo
1687 1686
                 $this->linkID->beginTransaction();
1688 1687
             } elseif ($this->transTimes > 1 && $this->supportSavepoint()) {
1689 1688
                 $this->linkID->exec(
1690
-                    $this->parseSavepoint('trans' . $this->transTimes)
1689
+                    $this->parseSavepoint('trans'.$this->transTimes)
1691 1690
                 );
1692 1691
             }
1693 1692
         } catch (\Exception $e) {
@@ -1730,7 +1729,7 @@  discard block
 block discarded – undo
1730 1729
             $this->linkID->rollBack();
1731 1730
         } elseif ($this->transTimes > 1 && $this->supportSavepoint()) {
1732 1731
             $this->linkID->exec(
1733
-                $this->parseSavepointRollBack('trans' . $this->transTimes)
1732
+                $this->parseSavepointRollBack('trans'.$this->transTimes)
1734 1733
             );
1735 1734
         }
1736 1735
 
@@ -1754,7 +1753,7 @@  discard block
 block discarded – undo
1754 1753
      */
1755 1754
     protected function parseSavepoint($name)
1756 1755
     {
1757
-        return 'SAVEPOINT ' . $name;
1756
+        return 'SAVEPOINT '.$name;
1758 1757
     }
1759 1758
 
1760 1759
     /**
@@ -1765,7 +1764,7 @@  discard block
 block discarded – undo
1765 1764
      */
1766 1765
     protected function parseSavepointRollBack($name)
1767 1766
     {
1768
-        return 'ROLLBACK TO SAVEPOINT ' . $name;
1767
+        return 'ROLLBACK TO SAVEPOINT '.$name;
1769 1768
     }
1770 1769
 
1771 1770
     /**
@@ -1900,13 +1899,13 @@  discard block
 block discarded – undo
1900 1899
     {
1901 1900
         if ($this->PDOStatement) {
1902 1901
             $error = $this->PDOStatement->errorInfo();
1903
-            $error = $error[1] . ':' . $error[2];
1902
+            $error = $error[1].':'.$error[2];
1904 1903
         } else {
1905 1904
             $error = '';
1906 1905
         }
1907 1906
 
1908 1907
         if ('' != $this->queryStr) {
1909
-            $error .= "\n [ SQL语句 ] : " . $this->getLastsql();
1908
+            $error .= "\n [ SQL语句 ] : ".$this->getLastsql();
1910 1909
         }
1911 1910
 
1912 1911
         return $error;
@@ -1983,10 +1982,10 @@  discard block
 block discarded – undo
1983 1982
             }
1984 1983
 
1985 1984
             // 未注册监听则记录到日志中
1986
-            $this->log('[ SQL ] ' . $sql . ' [ ' . $master . 'RunTime:' . $runtime . 's ]');
1985
+            $this->log('[ SQL ] '.$sql.' [ '.$master.'RunTime:'.$runtime.'s ]');
1987 1986
 
1988 1987
             if (!empty($explain)) {
1989
-                $this->log('[ EXPLAIN : ' . var_export($explain, true) . ' ]');
1988
+                $this->log('[ EXPLAIN : '.var_export($explain, true).' ]');
1990 1989
             }
1991 1990
         }
1992 1991
     }
@@ -2136,14 +2135,14 @@  discard block
 block discarded – undo
2136 2135
             $data = $value[2];
2137 2136
         }
2138 2137
 
2139
-        $prefix = 'think:' . $this->getConfig('database') . '.';
2138
+        $prefix = 'think:'.$this->getConfig('database').'.';
2140 2139
 
2141 2140
         if (isset($data)) {
2142
-            return $prefix . $query->getTable() . '|' . $data;
2141
+            return $prefix.$query->getTable().'|'.$data;
2143 2142
         }
2144 2143
 
2145 2144
         try {
2146
-            return md5($prefix . serialize($query->getOptions()) . serialize($query->getBind(false)));
2145
+            return md5($prefix.serialize($query->getOptions()).serialize($query->getBind(false)));
2147 2146
         } catch (\Exception $e) {
2148 2147
             throw new Exception('closure not support cache(true)');
2149 2148
         }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1812,9 +1812,11 @@
 block discarded – undo
1812 1812
 
1813 1813
         if ($this->config['rw_separate']) {
1814 1814
             // 主从式采用读写分离
1815
-            if ($master) // 主服务器写入
1815
+            if ($master) {
1816
+                // 主服务器写入
1816 1817
             {
1817 1818
                 $r = $m;
1819
+            }
1818 1820
             } elseif (is_numeric($this->config['slave_no'])) {
1819 1821
                 // 指定服务器读
1820 1822
                 $r = $this->config['slave_no'];
Please login to merge, or discard this patch.
library/think/db/connector/Sqlsrv.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function parseDsn($config)
40 40
     {
41
-        $dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname'];
41
+        $dsn = 'sqlsrv:Database='.$config['database'].';Server='.$config['hostname'];
42 42
 
43 43
         if (!empty($config['hostport'])) {
44
-            $dsn .= ',' . $config['hostport'];
44
+            $dsn .= ','.$config['hostport'];
45 45
         }
46 46
 
47 47
         return $dsn;
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         if (is_null($field)) {
161 161
             $field = '*';
162 162
         } elseif ($key && '*' != $field) {
163
-            $field = $key . ',' . $field;
163
+            $field = $key.','.$field;
164 164
         }
165 165
 
166 166
         if (is_string($field)) {
Please login to merge, or discard this patch.
library/think/db/connector/Sqlite.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     protected function parseDsn($config)
32 32
     {
33
-        $dsn = 'sqlite:' . $config['database'];
33
+        $dsn = 'sqlite:'.$config['database'];
34 34
 
35 35
         return $dsn;
36 36
     }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     public function getFields($tableName)
45 45
     {
46 46
         list($tableName) = explode(' ', $tableName);
47
-        $sql             = 'PRAGMA table_info( ' . $tableName . ' )';
47
+        $sql             = 'PRAGMA table_info( '.$tableName.' )';
48 48
 
49 49
         $pdo    = $this->query($sql, [], false, true);
50 50
         $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
library/think/db/connector/Pgsql.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,10 +37,10 @@  discard block
 block discarded – undo
37 37
      */
38 38
     protected function parseDsn($config)
39 39
     {
40
-        $dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
40
+        $dsn = 'pgsql:dbname='.$config['database'].';host='.$config['hostname'];
41 41
 
42 42
         if (!empty($config['hostport'])) {
43
-            $dsn .= ';port=' . $config['hostport'];
43
+            $dsn .= ';port='.$config['hostport'];
44 44
         }
45 45
 
46 46
         return $dsn;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     public function getFields($tableName)
56 56
     {
57 57
         list($tableName) = explode(' ', $tableName);
58
-        $sql             = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');';
58
+        $sql             = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\''.$tableName.'\');';
59 59
 
60 60
         $pdo    = $this->query($sql, [], false, true);
61 61
         $result = $pdo->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
library/think/Debug.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getThroughputRate()
111 111
     {
112
-        return number_format(1 / $this->getUseTime(), 2) . 'req/s';
112
+        return number_format(1 / $this->getUseTime(), 2).'req/s';
113 113
     }
114 114
 
115 115
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             $pos++;
136 136
         }
137 137
 
138
-        return round($size, $dec) . " " . $a[$pos];
138
+        return round($size, $dec)." ".$a[$pos];
139 139
     }
140 140
 
141 141
     /**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             $pos++;
156 156
         }
157 157
 
158
-        return round($size, $dec) . " " . $a[$pos];
158
+        return round($size, $dec)." ".$a[$pos];
159 159
     }
160 160
 
161 161
     /**
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             $pos++;
182 182
         }
183 183
 
184
-        return round($size, $dec) . " " . $a[$pos];
184
+        return round($size, $dec)." ".$a[$pos];
185 185
     }
186 186
 
187 187
     /**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
             $info  = [];
198 198
 
199 199
             foreach ($files as $key => $file) {
200
-                $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
200
+                $info[] = $file.' ( '.number_format(filesize($file) / 1024, 2).' KB )';
201 201
             }
202 202
 
203 203
             return $info;
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
      */
218 218
     public function dump($var, $echo = true, $label = null, $flags = ENT_SUBSTITUTE)
219 219
     {
220
-        $label = (null === $label) ? '' : rtrim($label) . ':';
220
+        $label = (null === $label) ? '' : rtrim($label).':';
221 221
         if ($var instanceof Model || $var instanceof ModelCollection) {
222 222
             $var = $var->toArray();
223 223
         }
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
         $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output);
230 230
 
231 231
         if (PHP_SAPI == 'cli') {
232
-            $output = PHP_EOL . $label . $output . PHP_EOL;
232
+            $output = PHP_EOL.$label.$output.PHP_EOL;
233 233
         } else {
234 234
             if (!extension_loaded('xdebug')) {
235 235
                 $output = htmlspecialchars($output, $flags);
236 236
             }
237
-            $output = '<pre>' . $label . $output . '</pre>';
237
+            $output = '<pre>'.$label.$output.'</pre>';
238 238
         }
239 239
         if ($echo) {
240 240
             echo($output);
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
                 // trace调试信息注入
261 261
                 $pos = strripos($content, '</body>');
262 262
                 if (false !== $pos) {
263
-                    $content = substr($content, 0, $pos) . $output . substr($content, $pos);
263
+                    $content = substr($content, 0, $pos).$output.substr($content, $pos);
264 264
                 } else {
265
-                    $content = $content . $output;
265
+                    $content = $content.$output;
266 266
                 }
267 267
             }
268 268
         }
Please login to merge, or discard this patch.
library/think/Config.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
     {
118 118
         if (is_file($file)) {
119 119
             $filename = $file;
120
-        } elseif (is_file($this->path . $file . $this->ext)) {
121
-            $filename = $this->path . $file . $this->ext;
120
+        } elseif (is_file($this->path.$file.$this->ext)) {
121
+            $filename = $this->path.$file.$this->ext;
122 122
         }
123 123
 
124 124
         if (isset($filename)) {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     protected function getYaconfName($name)
140 140
     {
141 141
         if ($this->yaconf && is_string($this->yaconf)) {
142
-            return $this->yaconf . '.' . $name;
142
+            return $this->yaconf.'.'.$name;
143 143
         }
144 144
 
145 145
         return $name;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     public function has($name)
189 189
     {
190 190
         if (false === strpos($name, '.')) {
191
-            $name = $this->prefix . '.' . $name;
191
+            $name = $this->prefix.'.'.$name;
192 192
         }
193 193
 
194 194
         return !is_null($this->get($name));
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
     public function get($name = null, $default = null)
227 227
     {
228 228
         if ($name && false === strpos($name, '.')) {
229
-            $name = $this->prefix . '.' . $name;
229
+            $name = $this->prefix.'.'.$name;
230 230
         }
231 231
 
232 232
         // 无参数时获取所有
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
     {
274 274
         if (is_string($name)) {
275 275
             if (false === strpos($name, '.')) {
276
-                $name = $this->prefix . '.' . $name;
276
+                $name = $this->prefix.'.'.$name;
277 277
             }
278 278
 
279 279
             $name = explode('.', $name, 3);
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     public function remove($name)
316 316
     {
317 317
         if (false === strpos($name, '.')) {
318
-            $name = $this->prefix . '.' . $name;
318
+            $name = $this->prefix.'.'.$name;
319 319
         }
320 320
 
321 321
         $name = explode('.', $name, 3);
Please login to merge, or discard this patch.
library/think/paginator/driver/Bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      */
137 137
     protected function getAvailablePageWrapper($url, $page)
138 138
     {
139
-        return '<li><a href="' . htmlentities($url) . '">' . $page . '</a></li>';
139
+        return '<li><a href="'.htmlentities($url).'">'.$page.'</a></li>';
140 140
     }
141 141
 
142 142
     /**
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     protected function getDisabledTextWrapper($text)
149 149
     {
150
-        return '<li class="disabled"><span>' . $text . '</span></li>';
150
+        return '<li class="disabled"><span>'.$text.'</span></li>';
151 151
     }
152 152
 
153 153
     /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     protected function getActivePageWrapper($text)
160 160
     {
161
-        return '<li class="active"><span>' . $text . '</span></li>';
161
+        return '<li class="active"><span>'.$text.'</span></li>';
162 162
     }
163 163
 
164 164
     /**
Please login to merge, or discard this patch.