@@ -132,23 +132,23 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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) { |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | if (!empty($whereClause)) { |
319 | 319 | $query->bind($newQuery->getBind(false)); |
320 | - $str[] = ' ' . $logic . ' ( ' . $whereClause . ' )'; |
|
320 | + $str[] = ' '.$logic.' ( '.$whereClause.' )'; |
|
321 | 321 | } |
322 | 322 | } elseif (is_array($field)) { |
323 | 323 | array_unshift($value, $field); |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | $str2[] = $this->parseWhereItem($query, array_shift($item), $item, $logic, $binds); |
327 | 327 | } |
328 | 328 | |
329 | - $str[] = ' ' . $logic . ' ( ' . implode(' AND ', $str2) . ' )'; |
|
329 | + $str[] = ' '.$logic.' ( '.implode(' AND ', $str2).' )'; |
|
330 | 330 | } elseif (strpos($field, '|')) { |
331 | 331 | // 不同字段使用相同查询条件(OR) |
332 | 332 | $array = explode('|', $field); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | $item[] = $this->parseWhereItem($query, $k, $value, '', $binds); |
337 | 337 | } |
338 | 338 | |
339 | - $str[] = ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )'; |
|
339 | + $str[] = ' '.$logic.' ( '.implode(' OR ', $item).' )'; |
|
340 | 340 | } elseif (strpos($field, '&')) { |
341 | 341 | // 不同字段使用相同查询条件(AND) |
342 | 342 | $array = explode('&', $field); |
@@ -346,11 +346,11 @@ discard block |
||
346 | 346 | $item[] = $this->parseWhereItem($query, $k, $value, '', $binds); |
347 | 347 | } |
348 | 348 | |
349 | - $str[] = ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )'; |
|
349 | + $str[] = ' '.$logic.' ( '.implode(' AND ', $item).' )'; |
|
350 | 350 | } else { |
351 | 351 | // 对字段使用表达式查询 |
352 | 352 | $field = is_string($field) ? $field : ''; |
353 | - $str[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $logic, $binds); |
|
353 | + $str[] = ' '.$logic.' '.$this->parseWhereItem($query, $field, $value, $logic, $binds); |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | $str[] = $this->parseWhereItem($query, $field, $item, $rule, $binds); |
389 | 389 | } |
390 | 390 | |
391 | - return '( ' . implode(' ' . $rule . ' ', $str) . ' )'; |
|
391 | + return '( '.implode(' '.$rule.' ', $str).' )'; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | // 检测操作符 |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | if (0 === strpos($value, ':') && $query->isBind(substr($value, 1))) { |
416 | 416 | } else { |
417 | 417 | $name = $query->bind($value, $bindType); |
418 | - $value = ':' . $name; |
|
418 | + $value = ':'.$name; |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | } |
429 | 429 | |
430 | 430 | if (!isset($whereStr)) { |
431 | - throw new Exception('where express error:' . $exp); |
|
431 | + throw new Exception('where express error:'.$exp); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | return $whereStr; |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | if (is_array($value)) { |
453 | 453 | foreach ($value as $item) { |
454 | 454 | $name = $query->bind($item, PDO::PARAM_STR); |
455 | - $array[] = $key . ' ' . $exp . ' :' . $name; |
|
455 | + $array[] = $key.' '.$exp.' :'.$name; |
|
456 | 456 | } |
457 | 457 | |
458 | - $whereStr = '(' . implode(' ' . strtoupper($logic) . ' ', $array) . ')'; |
|
458 | + $whereStr = '('.implode(' '.strtoupper($logic).' ', $array).')'; |
|
459 | 459 | } else { |
460 | - $whereStr = $key . ' ' . $exp . ' ' . $value; |
|
460 | + $whereStr = $key.' '.$exp.' '.$value; |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | return $whereStr; |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | list($op, $field2) = $value; |
481 | 481 | |
482 | 482 | if (!in_array($op, ['=', '<>', '>', '>=', '<', '<='])) { |
483 | - throw new Exception('where express error:' . var_export($value, true)); |
|
483 | + throw new Exception('where express error:'.var_export($value, true)); |
|
484 | 484 | } |
485 | 485 | |
486 | - return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field2, true) . ' )'; |
|
486 | + return '( '.$key.' '.$op.' '.$this->parseKey($query, $field2, true).' )'; |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | protected function parseExp(Query $query, $key, $exp, Expression $value, $field, $bindType) |
501 | 501 | { |
502 | 502 | // 表达式查询 |
503 | - return '( ' . $key . ' ' . $value->getValue() . ' )'; |
|
503 | + return '( '.$key.' '.$value->getValue().' )'; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | protected function parseNull(Query $query, $key, $exp, $value, $field, $bindType) |
518 | 518 | { |
519 | 519 | // NULL 查询 |
520 | - return $key . ' IS ' . $exp; |
|
520 | + return $key.' IS '.$exp; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | $min = $query->bind($data[0], $bindType); |
540 | 540 | $max = $query->bind($data[1], $bindType); |
541 | 541 | |
542 | - return $key . ' ' . $exp . ' :' . $min . ' AND :' . $max . ' '; |
|
542 | + return $key.' '.$exp.' :'.$min.' AND :'.$max.' '; |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | } elseif ($value instanceof Expression) { |
562 | 562 | $value = $value->getValue(); |
563 | 563 | } else { |
564 | - throw new Exception('where express error:' . $value); |
|
564 | + throw new Exception('where express error:'.$value); |
|
565 | 565 | } |
566 | 566 | |
567 | - return $exp . ' (' . $value . ')'; |
|
567 | + return $exp.' ('.$value.')'; |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | */ |
581 | 581 | protected function parseTime(Query $query, $key, $exp, $value, $field, $bindType) |
582 | 582 | { |
583 | - return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType); |
|
583 | + return $key.' '.substr($exp, 0, 2).' '.$this->parseDateTime($query, $value, $field, $bindType); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | protected function parseCompare(Query $query, $key, $exp, $value, $field, $bindType) |
598 | 598 | { |
599 | 599 | if (is_array($value)) { |
600 | - throw new Exception('where express error:' . $exp . var_export($value, true)); |
|
600 | + throw new Exception('where express error:'.$exp.var_export($value, true)); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | // 比较运算 |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | } |
607 | 607 | |
608 | 608 | if ('=' == $exp && is_null($value)) { |
609 | - return $key . ' IS NULL'; |
|
609 | + return $key.' IS NULL'; |
|
610 | 610 | } |
611 | 611 | |
612 | - return $key . ' ' . $exp . ' ' . $value; |
|
612 | + return $key.' '.$exp.' '.$value; |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $value = explode(',', $value); |
630 | 630 | } |
631 | 631 | |
632 | - return $key . ' ' . substr($exp, 0, -4) |
|
632 | + return $key.' '.substr($exp, 0, -4) |
|
633 | 633 | . $this->parseDateTime($query, $value[0], $field, $bindType) |
634 | 634 | . ' AND ' |
635 | 635 | . $this->parseDateTime($query, $value[1], $field, $bindType); |
@@ -660,18 +660,18 @@ discard block |
||
660 | 660 | |
661 | 661 | foreach ($value as $k => $v) { |
662 | 662 | $name = $query->bind($v, $bindType); |
663 | - $array[] = ':' . $name; |
|
663 | + $array[] = ':'.$name; |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | if (count($array) == 1) { |
667 | - return $key . ('IN' == $exp ? ' = ' : ' <> ') . $array[0]; |
|
667 | + return $key.('IN' == $exp ? ' = ' : ' <> ').$array[0]; |
|
668 | 668 | } else { |
669 | 669 | $zone = implode(',', $array); |
670 | 670 | $value = empty($zone) ? "''" : $zone; |
671 | 671 | } |
672 | 672 | } |
673 | 673 | |
674 | - return $key . ' ' . $exp . ' (' . $value . ')'; |
|
674 | + return $key.' '.$exp.' ('.$value.')'; |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | |
737 | 737 | $name = $query->bind($value, $bindType); |
738 | 738 | |
739 | - return ':' . $name; |
|
739 | + return ':'.$name; |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | */ |
749 | 749 | protected function parseLimit(Query $query, $limit) |
750 | 750 | { |
751 | - return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; |
|
751 | + return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT '.$limit.' ' : ''; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | } elseif (strpos($val, '=')) { |
775 | 775 | list($val1, $val2) = explode('=', $val, 2); |
776 | 776 | |
777 | - $condition[] = $this->parseKey($query, $val1) . '=' . $this->parseKey($query, $val2); |
|
777 | + $condition[] = $this->parseKey($query, $val1).'='.$this->parseKey($query, $val2); |
|
778 | 778 | } else { |
779 | 779 | $condition[] = $val; |
780 | 780 | } |
@@ -782,7 +782,7 @@ discard block |
||
782 | 782 | |
783 | 783 | $table = $this->parseTable($query, $table); |
784 | 784 | |
785 | - $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . implode(' AND ', $condition); |
|
785 | + $joinStr .= ' '.$type.' JOIN '.$table.' ON '.implode(' AND ', $condition); |
|
786 | 786 | } |
787 | 787 | } |
788 | 788 | |
@@ -807,22 +807,22 @@ discard block |
||
807 | 807 | $array[] = $this->parseRand($query); |
808 | 808 | } elseif (is_string($val)) { |
809 | 809 | if (is_numeric($key)) { |
810 | - list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); |
|
810 | + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val.' '); |
|
811 | 811 | } else { |
812 | 812 | $sort = $val; |
813 | 813 | } |
814 | 814 | |
815 | 815 | if (preg_match('/^[\w\.]+$/', $key)) { |
816 | 816 | $sort = strtoupper($sort); |
817 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
818 | - $array[] = $this->parseKey($query, $key, true) . $sort; |
|
817 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
818 | + $array[] = $this->parseKey($query, $key, true).$sort; |
|
819 | 819 | } else { |
820 | - throw new Exception('order express error:' . $key); |
|
820 | + throw new Exception('order express error:'.$key); |
|
821 | 821 | } |
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
825 | - return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); |
|
825 | + return empty($array) ? '' : ' ORDER BY '.implode(',', $array); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | $sort = strtoupper($sort); |
846 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
846 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
847 | 847 | |
848 | 848 | $options = $query->getOptions(); |
849 | 849 | $bind = $this->connection->getFieldsBind($options['table']); |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | $val[$k] = $this->parseDataBind($query, $key, $item, $bind); |
853 | 853 | } |
854 | 854 | |
855 | - return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort; |
|
855 | + return 'field('.$this->parseKey($query, $key, true).','.implode(',', $val).')'.$sort; |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | $val[] = $this->parseKey($query, $key); |
877 | 877 | } |
878 | 878 | |
879 | - return ' GROUP BY ' . implode(',', $val); |
|
879 | + return ' GROUP BY '.implode(',', $val); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | /** |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | */ |
889 | 889 | protected function parseHaving(Query $query, $having) |
890 | 890 | { |
891 | - return !empty($having) ? ' HAVING ' . $having : ''; |
|
891 | + return !empty($having) ? ' HAVING '.$having : ''; |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | $comment = strstr($comment, '*/', true); |
905 | 905 | } |
906 | 906 | |
907 | - return !empty($comment) ? ' /* ' . $comment . ' */' : ''; |
|
907 | + return !empty($comment) ? ' /* '.$comment.' */' : ''; |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | /** |
@@ -937,13 +937,13 @@ discard block |
||
937 | 937 | |
938 | 938 | foreach ($union as $u) { |
939 | 939 | if ($u instanceof \Closure) { |
940 | - $sql[] = $type . ' ' . $this->parseClosure($query, $u); |
|
940 | + $sql[] = $type.' '.$this->parseClosure($query, $u); |
|
941 | 941 | } elseif (is_string($u)) { |
942 | - $sql[] = $type . ' ( ' . $this->connection->parseSqlTable($u) . ' )'; |
|
942 | + $sql[] = $type.' ( '.$this->connection->parseSqlTable($u).' )'; |
|
943 | 943 | } |
944 | 944 | } |
945 | 945 | |
946 | - return ' ' . implode(' ', $sql); |
|
946 | + return ' '.implode(' ', $sql); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | if (is_bool($lock)) { |
975 | 975 | return $lock ? ' FOR UPDATE ' : ''; |
976 | 976 | } elseif (is_string($lock) && !empty($lock)) { |
977 | - return ' ' . trim($lock) . ' '; |
|
977 | + return ' '.trim($lock).' '; |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | foreach ($dataSet as $data) { |
1066 | 1066 | $data = $this->parseData($query, $data, $allowFields, $bind); |
1067 | 1067 | |
1068 | - $values[] = 'SELECT ' . implode(',', array_values($data)); |
|
1068 | + $values[] = 'SELECT '.implode(',', array_values($data)); |
|
1069 | 1069 | |
1070 | 1070 | if (!isset($insertFields)) { |
1071 | 1071 | $insertFields = array_keys($data); |
@@ -1108,7 +1108,7 @@ discard block |
||
1108 | 1108 | $field = $this->parseKey($query, $field, true); |
1109 | 1109 | } |
1110 | 1110 | |
1111 | - return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query); |
|
1111 | + return 'INSERT INTO '.$this->parseTable($query, $table).' ('.implode(',', $fields).') '.$this->select($query); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | 1114 | /** |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | foreach ($data as $key => $val) { |
1131 | - $set[] = $key . ' = ' . $val; |
|
1131 | + $set[] = $key.' = '.$val; |
|
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | return str_replace( |
@@ -1160,7 +1160,7 @@ discard block |
||
1160 | 1160 | ['%TABLE%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], |
1161 | 1161 | [ |
1162 | 1162 | $this->parseTable($query, $options['table']), |
1163 | - !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', |
|
1163 | + !empty($options['using']) ? ' USING '.$this->parseTable($query, $options['using']).' ' : '', |
|
1164 | 1164 | $this->parseJoin($query, $options['join']), |
1165 | 1165 | $this->parseWhere($query, $options['where']), |
1166 | 1166 | $this->parseOrder($query, $options['order']), |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | } |
44 | 44 | |
45 | 45 | if (empty($this->options['path'])) { |
46 | - $this->options['path'] = Container::get('app')->getRuntimePath() . 'cache' . DIRECTORY_SEPARATOR; |
|
46 | + $this->options['path'] = Container::get('app')->getRuntimePath().'cache'.DIRECTORY_SEPARATOR; |
|
47 | 47 | } elseif (substr($this->options['path'], -1) != DIRECTORY_SEPARATOR) { |
48 | 48 | $this->options['path'] .= DIRECTORY_SEPARATOR; |
49 | 49 | } |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | |
83 | 83 | if ($this->options['cache_subdir']) { |
84 | 84 | // 使用子目录 |
85 | - $name = substr($name, 0, 2) . DIRECTORY_SEPARATOR . substr($name, 2); |
|
85 | + $name = substr($name, 0, 2).DIRECTORY_SEPARATOR.substr($name, 2); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | if ($this->options['prefix']) { |
89 | - $name = $this->options['prefix'] . DIRECTORY_SEPARATOR . $name; |
|
89 | + $name = $this->options['prefix'].DIRECTORY_SEPARATOR.$name; |
|
90 | 90 | } |
91 | 91 | |
92 | - $filename = $this->options['path'] . $name . '.php'; |
|
92 | + $filename = $this->options['path'].$name.'.php'; |
|
93 | 93 | $dir = dirname($filename); |
94 | 94 | |
95 | 95 | if ($auto && !is_dir($dir)) { |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $data = gzcompress($data, 3); |
185 | 185 | } |
186 | 186 | |
187 | - $data = "<?php\n//" . sprintf('%012d', $expire) . "\n exit();?>\n" . $data; |
|
187 | + $data = "<?php\n//".sprintf('%012d', $expire)."\n exit();?>\n".$data; |
|
188 | 188 | $result = file_put_contents($filename, $data); |
189 | 189 | |
190 | 190 | if ($result) { |
@@ -272,13 +272,13 @@ discard block |
||
272 | 272 | |
273 | 273 | $this->writeTimes++; |
274 | 274 | |
275 | - $files = (array) glob($this->options['path'] . ($this->options['prefix'] ? $this->options['prefix'] . DIRECTORY_SEPARATOR : '') . '*'); |
|
275 | + $files = (array) glob($this->options['path'].($this->options['prefix'] ? $this->options['prefix'].DIRECTORY_SEPARATOR : '').'*'); |
|
276 | 276 | |
277 | 277 | foreach ($files as $path) { |
278 | 278 | if (is_dir($path)) { |
279 | - $matches = glob($path . DIRECTORY_SEPARATOR . '*.php'); |
|
279 | + $matches = glob($path.DIRECTORY_SEPARATOR.'*.php'); |
|
280 | 280 | if (is_array($matches)) { |
281 | - array_map(function ($v) { |
|
281 | + array_map(function($v) { |
|
282 | 282 | $this->unlink($v); |
283 | 283 | }, $matches); |
284 | 284 | } |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | $this->app = $app; |
43 | 43 | $this->config = $config; |
44 | 44 | |
45 | - if (is_file($app->getRuntimePath() . 'route.php')) { |
|
45 | + if (is_file($app->getRuntimePath().'route.php')) { |
|
46 | 46 | // 读取路由映射文件 |
47 | - $app['route']->setName(include $app->getRuntimePath() . 'route.php'); |
|
47 | + $app['route']->setName(include $app->getRuntimePath().'route.php'); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { |
80 | 80 | // [name] 表示使用路由命名标识生成URL |
81 | 81 | $name = substr($url, 1, $pos - 1); |
82 | - $url = 'name' . substr($url, $pos + 1); |
|
82 | + $url = 'name'.substr($url, $pos + 1); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | if ($url) { |
115 | - $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : ''); |
|
115 | + $checkName = isset($name) ? $name : $url.(isset($info['query']) ? '?'.$info['query'] : ''); |
|
116 | 116 | $checkDomain = $domain && is_string($domain) ? $domain : null; |
117 | 117 | |
118 | 118 | $rule = $this->app['route']->getName($checkName, $checkDomain); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $suffix = $match[2]; |
139 | 139 | } |
140 | 140 | } elseif (!empty($rule) && isset($name)) { |
141 | - throw new \InvalidArgumentException('route name not exists:' . $name); |
|
141 | + throw new \InvalidArgumentException('route name not exists:'.$name); |
|
142 | 142 | } else { |
143 | 143 | // 检查别名路由 |
144 | 144 | $alias = $this->app['route']->getAlias(); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $val = $item->getRoute(); |
151 | 151 | |
152 | 152 | if (0 === strpos($url, $val)) { |
153 | - $url = $key . substr($url, strlen($val)); |
|
153 | + $url = $key.substr($url, strlen($val)); |
|
154 | 154 | $matchAlias = true; |
155 | 155 | break; |
156 | 156 | } |
@@ -200,38 +200,38 @@ discard block |
||
200 | 200 | } |
201 | 201 | |
202 | 202 | // 锚点 |
203 | - $anchor = !empty($anchor) ? '#' . $anchor : ''; |
|
203 | + $anchor = !empty($anchor) ? '#'.$anchor : ''; |
|
204 | 204 | |
205 | 205 | // 参数组装 |
206 | 206 | if (!empty($vars)) { |
207 | 207 | // 添加参数 |
208 | 208 | if ($this->config['url_common_param']) { |
209 | 209 | $vars = http_build_query($vars); |
210 | - $url .= $suffix . '?' . $vars . $anchor; |
|
210 | + $url .= $suffix.'?'.$vars.$anchor; |
|
211 | 211 | } else { |
212 | 212 | $paramType = $this->config['url_param_type']; |
213 | 213 | |
214 | 214 | foreach ($vars as $var => $val) { |
215 | 215 | if ('' !== trim($val)) { |
216 | 216 | if ($paramType) { |
217 | - $url .= $depr . urlencode($val); |
|
217 | + $url .= $depr.urlencode($val); |
|
218 | 218 | } else { |
219 | - $url .= $depr . $var . $depr . urlencode($val); |
|
219 | + $url .= $depr.$var.$depr.urlencode($val); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
224 | - $url .= $suffix . $anchor; |
|
224 | + $url .= $suffix.$anchor; |
|
225 | 225 | } |
226 | 226 | } else { |
227 | - $url .= $suffix . $anchor; |
|
227 | + $url .= $suffix.$anchor; |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | // 检测域名 |
231 | 231 | $domain = $this->parseDomain($url, $domain); |
232 | 232 | |
233 | 233 | // URL组装 |
234 | - $url = $domain . rtrim($this->root ?: $this->app['request']->root(), '/') . '/' . ltrim($url, '/'); |
|
234 | + $url = $domain.rtrim($this->root ?: $this->app['request']->root(), '/').'/'.ltrim($url, '/'); |
|
235 | 235 | |
236 | 236 | $this->bindCheck = false; |
237 | 237 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | } else { |
256 | 256 | // 解析到 模块/控制器/操作 |
257 | 257 | $module = $request->module(); |
258 | - $module = $module ? $module . '/' : ''; |
|
258 | + $module = $module ? $module.'/' : ''; |
|
259 | 259 | $controller = $request->controller(); |
260 | 260 | |
261 | 261 | if ('' == $url) { |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $path = explode('/', $url); |
265 | 265 | $action = array_pop($path); |
266 | 266 | $controller = empty($path) ? $controller : array_pop($path); |
267 | - $module = empty($path) ? $module : array_pop($path) . '/'; |
|
267 | + $module = empty($path) ? $module : array_pop($path).'/'; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | if ($this->config['url_convert']) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $controller = Loader::parseName($controller); |
273 | 273 | } |
274 | 274 | |
275 | - $url = $module . $controller . '/' . $action; |
|
275 | + $url = $module.$controller.'/'.$action; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $url; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | } |
320 | 320 | } |
321 | 321 | } elseif (0 !== strpos($domain, $rootDomain) && false === strpos($domain, '.')) { |
322 | - $domain .= '.' . $rootDomain; |
|
322 | + $domain .= '.'.$rootDomain; |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | if (false !== strpos($domain, '://')) { |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | |
330 | 330 | } |
331 | 331 | |
332 | - return $scheme . $domain; |
|
332 | + return $scheme.$domain; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | // 解析URL后缀 |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - return (empty($suffix) || 0 === strpos($suffix, '.')) ? $suffix : '.' . $suffix; |
|
346 | + return (empty($suffix) || 0 === strpos($suffix, '.')) ? $suffix : '.'.$suffix; |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | // 匹配路由地址 |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | } |
359 | 359 | |
360 | 360 | if ($port && !in_array($port, [80, 443])) { |
361 | - $domain .= ':' . $port; |
|
361 | + $domain .= ':'.$port; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | if (empty($pattern)) { |
@@ -370,12 +370,12 @@ discard block |
||
370 | 370 | |
371 | 371 | foreach ($pattern as $key => $val) { |
372 | 372 | if (isset($vars[$key])) { |
373 | - $url = str_replace(['[:' . $key . ']', '<' . $key . '?>', ':' . $key, '<' . $key . '>'], $type ? $vars[$key] : urlencode($vars[$key]), $url); |
|
373 | + $url = str_replace(['[:'.$key.']', '<'.$key.'?>', ':'.$key, '<'.$key.'>'], $type ? $vars[$key] : urlencode($vars[$key]), $url); |
|
374 | 374 | $keys[] = $key; |
375 | 375 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
376 | 376 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
377 | 377 | } elseif (2 == $val) { |
378 | - $url = str_replace(['/[:' . $key . ']', '[:' . $key . ']', '<' . $key . '?>'], '', $url); |
|
378 | + $url = str_replace(['/[:'.$key.']', '[:'.$key.']', '<'.$key.'?>'], '', $url); |
|
379 | 379 | $url = str_replace(['/?', '-?'], ['/', '-'], $url); |
380 | 380 | $result = [rtrim($url, '?/-'), $domain, $suffix]; |
381 | 381 | } else { |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | if (!empty($bind) && preg_match('/^[a-z]/is', $bind)) { |
43 | 43 | $bind = str_replace('/', $depr, $bind); |
44 | 44 | // 如果有模块/控制器绑定 |
45 | - $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr); |
|
45 | + $url = $bind.('.' != substr($bind, -1) ? $depr : '').ltrim($url, $depr); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | list($path, $var) = $this->rule->parseUrlPath($url); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | } |
62 | 62 | |
63 | 63 | if ($controller && !preg_match('/^[A-Za-z0-9][\w|\.]*$/', $controller)) { |
64 | - throw new HttpException(404, 'controller not exists:' . $controller); |
|
64 | + throw new HttpException(404, 'controller not exists:'.$controller); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // 解析操作 |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if ($this->rule->getConfig('url_param_type')) { |
73 | 73 | $var += $path; |
74 | 74 | } else { |
75 | - preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) { |
|
75 | + preg_replace_callback('/(\w+)\|([^\|]+)/', function($match) use (&$var) { |
|
76 | 76 | $var[$match[1]] = strip_tags($match[2]); |
77 | 77 | }, implode('|', $path)); |
78 | 78 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $route = [$module, $controller, $action]; |
93 | 93 | |
94 | 94 | if ($this->hasDefinedRoute($route, $bind)) { |
95 | - throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url)); |
|
95 | + throw new HttpException(404, 'invalid request:'.str_replace('|', $depr, $url)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $route; |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | list($module, $controller, $action) = $route; |
111 | 111 | |
112 | 112 | // 检查地址是否被定义过路由 |
113 | - $name = strtolower($module . '/' . Loader::parseName($controller, 1) . '/' . $action); |
|
113 | + $name = strtolower($module.'/'.Loader::parseName($controller, 1).'/'.$action); |
|
114 | 114 | |
115 | 115 | $name2 = ''; |
116 | 116 | |
117 | 117 | if (empty($module) || $module == $bind) { |
118 | - $name2 = strtolower(Loader::parseName($controller, 1) . '/' . $action); |
|
118 | + $name2 = strtolower(Loader::parseName($controller, 1).'/'.$action); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $host = $this->request->host(true); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function autoFindController($module, &$path) |
140 | 140 | { |
141 | - $dir = $this->app->getAppPath() . ($module ? $module . '/' : '') . $this->rule->getConfig('url_controller_layer'); |
|
141 | + $dir = $this->app->getAppPath().($module ? $module.'/' : '').$this->rule->getConfig('url_controller_layer'); |
|
142 | 142 | $suffix = $this->app->getSuffix() || $this->rule->getConfig('controller_suffix') ? ucfirst($this->rule->getConfig('url_controller_layer')) : ''; |
143 | 143 | |
144 | 144 | $item = []; |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | |
147 | 147 | foreach ($path as $val) { |
148 | 148 | $item[] = $val; |
149 | - $file = $dir . '/' . str_replace('.', '/', $val) . $suffix . '.php'; |
|
150 | - $file = pathinfo($file, PATHINFO_DIRNAME) . '/' . Loader::parseName(pathinfo($file, PATHINFO_FILENAME), 1) . '.php'; |
|
149 | + $file = $dir.'/'.str_replace('.', '/', $val).$suffix.'.php'; |
|
150 | + $file = pathinfo($file, PATHINFO_DIRNAME).'/'.Loader::parseName(pathinfo($file, PATHINFO_FILENAME), 1).'.php'; |
|
151 | 151 | if (is_file($file)) { |
152 | 152 | $find = true; |
153 | 153 | break; |
154 | 154 | } else { |
155 | - $dir .= '/' . Loader::parseName($val); |
|
155 | + $dir .= '/'.Loader::parseName($val); |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 |
@@ -189,15 +189,15 @@ discard block |
||
189 | 189 | $name = Loader::parseName(substr($method, 5)); |
190 | 190 | array_unshift($args, $name); |
191 | 191 | return call_user_func_array([$this, 'where'], $args); |
192 | - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { |
|
192 | + } elseif ($this->model && method_exists($this->model, 'scope'.$method)) { |
|
193 | 193 | // 动态调用命名范围 |
194 | - $method = 'scope' . $method; |
|
194 | + $method = 'scope'.$method; |
|
195 | 195 | array_unshift($args, $this); |
196 | 196 | |
197 | 197 | call_user_func_array([$this->model, $method], $args); |
198 | 198 | return $this; |
199 | 199 | } else { |
200 | - throw new Exception('method not exist:' . ($this->model ? get_class($this->model) : static::class) . '->' . $method); |
|
200 | + throw new Exception('method not exist:'.($this->model ? get_class($this->model) : static::class).'->'.$method); |
|
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | |
317 | 317 | $name = $name ?: $this->name; |
318 | 318 | |
319 | - return $this->prefix . Loader::parseName($name); |
|
319 | + return $this->prefix.Loader::parseName($name); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -588,16 +588,16 @@ discard block |
||
588 | 588 | $seq = (ord(substr($value, 0, 1)) % $rule['num']) + 1; |
589 | 589 | } |
590 | 590 | |
591 | - return $this->getTable() . '_' . $seq; |
|
591 | + return $this->getTable().'_'.$seq; |
|
592 | 592 | } |
593 | 593 | // 当设置的分表字段不在查询条件或者数据中 |
594 | 594 | // 进行联合查询,必须设定 partition['num'] |
595 | 595 | $tableName = []; |
596 | 596 | for ($i = 0; $i < $rule['num']; $i++) { |
597 | - $tableName[] = 'SELECT * FROM ' . $this->getTable() . '_' . ($i + 1); |
|
597 | + $tableName[] = 'SELECT * FROM '.$this->getTable().'_'.($i + 1); |
|
598 | 598 | } |
599 | 599 | |
600 | - return ['( ' . implode(" UNION ", $tableName) . ' )' => $this->name]; |
|
600 | + return ['( '.implode(" UNION ", $tableName).' )' => $this->name]; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | // 支持GROUP |
664 | 664 | $options = $this->getOptions(); |
665 | 665 | $subSql = $this->options($options) |
666 | - ->field('count(' . $field . ') AS think_count') |
|
666 | + ->field('count('.$field.') AS think_count') |
|
667 | 667 | ->bind($this->bind) |
668 | 668 | ->buildSql(); |
669 | 669 | |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | if ($lazyTime > 0) { |
768 | 768 | // 延迟写入 |
769 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
769 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
770 | 770 | $step = $this->lazyWrite('inc', $guid, $step, $lazyTime); |
771 | 771 | |
772 | 772 | if (false === $step) { |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | |
800 | 800 | if ($lazyTime > 0) { |
801 | 801 | // 延迟写入 |
802 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
802 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
803 | 803 | $step = $this->lazyWrite('dec', $guid, $step, $lazyTime); |
804 | 804 | |
805 | 805 | if (false === $step) { |
@@ -830,15 +830,15 @@ discard block |
||
830 | 830 | { |
831 | 831 | $cache = Container::get('cache'); |
832 | 832 | |
833 | - if (!$cache->has($guid . '_time')) { |
|
833 | + if (!$cache->has($guid.'_time')) { |
|
834 | 834 | // 计时开始 |
835 | - $cache->set($guid . '_time', time(), 0); |
|
835 | + $cache->set($guid.'_time', time(), 0); |
|
836 | 836 | $cache->$type($guid, $step); |
837 | - } elseif (time() > $cache->get($guid . '_time') + $lazyTime) { |
|
837 | + } elseif (time() > $cache->get($guid.'_time') + $lazyTime) { |
|
838 | 838 | // 删除缓存 |
839 | 839 | $value = $cache->$type($guid, $step); |
840 | 840 | $cache->rm($guid); |
841 | - $cache->rm($guid . '_time'); |
|
841 | + $cache->rm($guid.'_time'); |
|
842 | 842 | return 0 === $value ? false : $value; |
843 | 843 | } else { |
844 | 844 | // 更新缓存 |
@@ -1037,10 +1037,10 @@ discard block |
||
1037 | 1037 | $prefix = $prefix ?: $tableName; |
1038 | 1038 | foreach ($field as $key => &$val) { |
1039 | 1039 | if (is_numeric($key) && $alias) { |
1040 | - $field[$prefix . '.' . $val] = $alias . $val; |
|
1040 | + $field[$prefix.'.'.$val] = $alias.$val; |
|
1041 | 1041 | unset($field[$key]); |
1042 | 1042 | } elseif (is_numeric($key)) { |
1043 | - $val = $prefix . '.' . $val; |
|
1043 | + $val = $prefix.'.'.$val; |
|
1044 | 1044 | } |
1045 | 1045 | } |
1046 | 1046 | } |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | $table = $this->getJoinTable($join, $alias); |
1168 | 1168 | |
1169 | 1169 | if (true === $field) { |
1170 | - $fields = $alias . '.*'; |
|
1170 | + $fields = $alias.'.*'; |
|
1171 | 1171 | } else { |
1172 | 1172 | if (is_string($field)) { |
1173 | 1173 | $field = explode(',', $field); |
@@ -1175,17 +1175,17 @@ discard block |
||
1175 | 1175 | |
1176 | 1176 | foreach ($field as $key => $val) { |
1177 | 1177 | if (is_numeric($key)) { |
1178 | - $fields[] = $alias . '.' . $val; |
|
1178 | + $fields[] = $alias.'.'.$val; |
|
1179 | 1179 | |
1180 | - $this->options['map'][$val] = $alias . '.' . $val; |
|
1180 | + $this->options['map'][$val] = $alias.'.'.$val; |
|
1181 | 1181 | } else { |
1182 | 1182 | if (preg_match('/[,=\.\'\"\(\s]/', $key)) { |
1183 | 1183 | $name = $key; |
1184 | 1184 | } else { |
1185 | - $name = $alias . '.' . $key; |
|
1185 | + $name = $alias.'.'.$key; |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | - $fields[] = $name . ' AS ' . $val; |
|
1188 | + $fields[] = $name.' AS '.$val; |
|
1189 | 1189 | |
1190 | 1190 | $this->options['map'][$val] = $name; |
1191 | 1191 | } |
@@ -1498,9 +1498,9 @@ discard block |
||
1498 | 1498 | } |
1499 | 1499 | |
1500 | 1500 | if (is_numeric($key)) { |
1501 | - $sql = substr_replace($sql, ':' . $name, strpos($sql, '?'), 1); |
|
1501 | + $sql = substr_replace($sql, ':'.$name, strpos($sql, '?'), 1); |
|
1502 | 1502 | } else { |
1503 | - $sql = str_replace(':' . $key, ':' . $name, $sql); |
|
1503 | + $sql = str_replace(':'.$key, ':'.$name, $sql); |
|
1504 | 1504 | } |
1505 | 1505 | } |
1506 | 1506 | } |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | if (is_string($field) && !empty($this->options['via']) && false === strpos($field, '.')) { |
1547 | - $field = $this->options['via'] . '.' . $field; |
|
1547 | + $field = $this->options['via'].'.'.$field; |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | if ($field instanceof Expression) { |
@@ -1728,7 +1728,7 @@ discard block |
||
1728 | 1728 | list($offset, $length) = explode(',', $offset); |
1729 | 1729 | } |
1730 | 1730 | |
1731 | - $this->options['limit'] = intval($offset) . ($length ? ',' . intval($length) : ''); |
|
1731 | + $this->options['limit'] = intval($offset).($length ? ','.intval($length) : ''); |
|
1732 | 1732 | |
1733 | 1733 | return $this; |
1734 | 1734 | } |
@@ -1785,7 +1785,7 @@ discard block |
||
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | /** @var Paginator $class */ |
1788 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']); |
|
1788 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\'.ucwords($config['type']); |
|
1789 | 1789 | $page = isset($config['page']) ? (int) $config['page'] : call_user_func([ |
1790 | 1790 | $class, |
1791 | 1791 | 'getCurrentPage', |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | |
1896 | 1896 | if (is_string($field)) { |
1897 | 1897 | if (!empty($this->options['via'])) { |
1898 | - $field = $this->options['via'] . '.' . $field; |
|
1898 | + $field = $this->options['via'].'.'.$field; |
|
1899 | 1899 | } |
1900 | 1900 | |
1901 | 1901 | if (strpos($field, ',')) { |
@@ -1906,9 +1906,9 @@ discard block |
||
1906 | 1906 | } elseif (!empty($this->options['via'])) { |
1907 | 1907 | foreach ($field as $key => $val) { |
1908 | 1908 | if (is_numeric($key)) { |
1909 | - $field[$key] = $this->options['via'] . '.' . $val; |
|
1909 | + $field[$key] = $this->options['via'].'.'.$val; |
|
1910 | 1910 | } else { |
1911 | - $field[$this->options['via'] . '.' . $key] = $val; |
|
1911 | + $field[$this->options['via'].'.'.$key] = $val; |
|
1912 | 1912 | unset($field[$key]); |
1913 | 1913 | } |
1914 | 1914 | } |
@@ -2320,7 +2320,7 @@ discard block |
||
2320 | 2320 | if ($this->model) { |
2321 | 2321 | // 检查模型类的查询范围方法 |
2322 | 2322 | foreach ($scope as $name) { |
2323 | - $method = 'scope' . trim($name); |
|
2323 | + $method = 'scope'.trim($name); |
|
2324 | 2324 | |
2325 | 2325 | if (method_exists($this->model, $method)) { |
2326 | 2326 | call_user_func_array([$this->model, $method], $args); |
@@ -2347,7 +2347,7 @@ discard block |
||
2347 | 2347 | } elseif ($this->model) { |
2348 | 2348 | // 检测搜索器 |
2349 | 2349 | $fieldName = is_numeric($key) ? $field : $key; |
2350 | - $method = 'search' . Loader::parseName($fieldName, 1) . 'Attr'; |
|
2350 | + $method = 'search'.Loader::parseName($fieldName, 1).'Attr'; |
|
2351 | 2351 | |
2352 | 2352 | if (method_exists($this->model, $method)) { |
2353 | 2353 | $this->model->$method($this, isset($data[$field]) ? $data[$field] : null, $data, $prefix); |
@@ -2412,7 +2412,7 @@ discard block |
||
2412 | 2412 | $op = is_array($range) ? 'between' : '>='; |
2413 | 2413 | } |
2414 | 2414 | |
2415 | - return $this->parseWhereExp($logic, $field, strtolower($op) . ' time', $range, [], true); |
|
2415 | + return $this->parseWhereExp($logic, $field, strtolower($op).' time', $range, [], true); |
|
2416 | 2416 | } |
2417 | 2417 | |
2418 | 2418 | /** |
@@ -2490,7 +2490,7 @@ discard block |
||
2490 | 2490 | if (is_array($value)) { |
2491 | 2491 | $this->bind = array_merge($this->bind, $value); |
2492 | 2492 | } else { |
2493 | - $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_' . mt_rand() . '_'; |
|
2493 | + $name = $name ?: 'ThinkBind_'.(count($this->bind) + 1).'_'.mt_rand().'_'; |
|
2494 | 2494 | |
2495 | 2495 | $this->bind[$name] = [$value, $type]; |
2496 | 2496 | return $name; |
@@ -2707,10 +2707,10 @@ discard block |
||
2707 | 2707 | $count = $this->model->$relation()->getRelationCountQuery($closure, $aggregate, $field, $aggregateField); |
2708 | 2708 | |
2709 | 2709 | if (empty($aggregateField)) { |
2710 | - $aggregateField = Loader::parseName($relation) . '_' . $aggregate; |
|
2710 | + $aggregateField = Loader::parseName($relation).'_'.$aggregate; |
|
2711 | 2711 | } |
2712 | 2712 | |
2713 | - $this->field(['(' . $count . ')' => $aggregateField]); |
|
2713 | + $this->field(['('.$count.')' => $aggregateField]); |
|
2714 | 2714 | } |
2715 | 2715 | } |
2716 | 2716 | |
@@ -3429,10 +3429,10 @@ discard block |
||
3429 | 3429 | { |
3430 | 3430 | if (!empty($this->model)) { |
3431 | 3431 | $class = get_class($this->model); |
3432 | - throw new ModelNotFoundException('model data Not Found:' . $class, $class, $options); |
|
3432 | + throw new ModelNotFoundException('model data Not Found:'.$class, $class, $options); |
|
3433 | 3433 | } |
3434 | 3434 | $table = is_array($options['table']) ? key($options['table']) : $options['table']; |
3435 | - throw new DataNotFoundException('table data not Found:' . $table, $table, $options); |
|
3435 | + throw new DataNotFoundException('table data not Found:'.$table, $table, $options); |
|
3436 | 3436 | } |
3437 | 3437 | |
3438 | 3438 | /** |
@@ -3568,7 +3568,7 @@ discard block |
||
3568 | 3568 | */ |
3569 | 3569 | public function buildSql($sub = true) |
3570 | 3570 | { |
3571 | - return $sub ? '( ' . $this->select(false) . ' )' : $this->select(false); |
|
3571 | + return $sub ? '( '.$this->select(false).' )' : $this->select(false); |
|
3572 | 3572 | } |
3573 | 3573 | |
3574 | 3574 | /** |
@@ -3639,7 +3639,7 @@ discard block |
||
3639 | 3639 | } |
3640 | 3640 | |
3641 | 3641 | if (is_string($pk)) { |
3642 | - $key = isset($alias) ? $alias . '.' . $pk : $pk; |
|
3642 | + $key = isset($alias) ? $alias.'.'.$pk : $pk; |
|
3643 | 3643 | // 根据主键查询 |
3644 | 3644 | if (is_array($data)) { |
3645 | 3645 | $where[$pk] = isset($data[$pk]) ? [$key, '=', $data[$pk]] : [$key, 'in', $data]; |
@@ -3650,7 +3650,7 @@ discard block |
||
3650 | 3650 | // 根据复合主键查询 |
3651 | 3651 | foreach ($pk as $key) { |
3652 | 3652 | if (isset($data[$key])) { |
3653 | - $attr = isset($alias) ? $alias . '.' . $key : $key; |
|
3653 | + $attr = isset($alias) ? $alias.'.'.$key : $key; |
|
3654 | 3654 | $where[$key] = [$attr, '=', $data[$key]]; |
3655 | 3655 | } else { |
3656 | 3656 | throw new Exception('miss complex primary data'); |
@@ -3726,7 +3726,7 @@ discard block |
||
3726 | 3726 | $page = $page > 0 ? $page : 1; |
3727 | 3727 | $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); |
3728 | 3728 | $offset = $listRows * ($page - 1); |
3729 | - $options['limit'] = $offset . ',' . $listRows; |
|
3729 | + $options['limit'] = $offset.','.$listRows; |
|
3730 | 3730 | } |
3731 | 3731 | |
3732 | 3732 | $this->options = $options; |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | foreach ($dataSet as $k => $data) { |
65 | 65 | $data = $this->parseData($query, $data, $allowFields, $bind); |
66 | 66 | |
67 | - $values[] = '( ' . implode(',', array_values($data)) . ' )'; |
|
67 | + $values[] = '( '.implode(',', array_values($data)).' )'; |
|
68 | 68 | |
69 | 69 | if (!isset($insertFields)) { |
70 | 70 | $insertFields = array_keys($data); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $value = $value->getValue(); |
105 | 105 | } |
106 | 106 | |
107 | - return $key . ' ' . $exp . ' ' . $value; |
|
107 | + return $key.' '.$exp.' '.$value; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | |
126 | 126 | $key = trim($key); |
127 | 127 | |
128 | - if(strpos($key, '->>') && false === strpos($key, '(')){ |
|
128 | + if (strpos($key, '->>') && false === strpos($key, '(')) { |
|
129 | 129 | // JSON字段支持 |
130 | 130 | list($field, $name) = explode('->>', $key, 2); |
131 | 131 | |
132 | - return $this->parseKey($query, $field, true) . '->>\'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->>', '.', $name) . '\''; |
|
132 | + return $this->parseKey($query, $field, true).'->>\'$'.(strpos($name, '[') === 0 ? '' : '.').str_replace('->>', '.', $name).'\''; |
|
133 | 133 | } |
134 | 134 | elseif (strpos($key, '->') && false === strpos($key, '(')) { |
135 | 135 | // JSON字段支持 |
136 | 136 | list($field, $name) = explode('->', $key, 2); |
137 | 137 | |
138 | - return 'json_extract(' . $this->parseKey($query, $field, true) . ', \'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->', '.', $name) . '\')'; |
|
138 | + return 'json_extract('.$this->parseKey($query, $field, true).', \'$'.(strpos($name, '[') === 0 ? '' : '.').str_replace('->', '.', $name).'\')'; |
|
139 | 139 | } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { |
140 | 140 | list($table, $key) = explode('.', $key, 2); |
141 | 141 | |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | } |
153 | 153 | |
154 | 154 | if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { |
155 | - throw new Exception('not support data:' . $key); |
|
155 | + throw new Exception('not support data:'.$key); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { |
159 | - $key = '`' . $key . '`'; |
|
159 | + $key = '`'.$key.'`'; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | if (isset($table)) { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $table = str_replace('.', '`.`', $table); |
165 | 165 | } |
166 | 166 | |
167 | - $key = '`' . $table . '`.' . $key; |
|
167 | + $key = '`'.$table.'`.'.$key; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | return $key; |
@@ -130,8 +130,7 @@ |
||
130 | 130 | list($field, $name) = explode('->>', $key, 2); |
131 | 131 | |
132 | 132 | return $this->parseKey($query, $field, true) . '->>\'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->>', '.', $name) . '\''; |
133 | - } |
|
134 | - elseif (strpos($key, '->') && false === strpos($key, '(')) { |
|
133 | + } elseif (strpos($key, '->') && false === strpos($key, '(')) { |
|
135 | 134 | // JSON字段支持 |
136 | 135 | list($field, $name) = explode('->', $key, 2); |
137 | 136 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | return $this->query |
92 | - ->whereExp($this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->localKey) |
|
92 | + ->whereExp($this->foreignKey, '='.$this->parent->getTable().'.'.$this->localKey) |
|
93 | 93 | ->fetchSql() |
94 | 94 | ->$aggregate($field); |
95 | 95 | } |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | |
145 | 145 | return $this->parent->db() |
146 | 146 | ->alias($model) |
147 | - ->whereExists(function ($query) use ($table, $model, $relation, $localKey, $foreignKey, $softDelete) { |
|
147 | + ->whereExists(function($query) use ($table, $model, $relation, $localKey, $foreignKey, $softDelete) { |
|
148 | 148 | $query->table([$table => $relation]) |
149 | - ->field($relation . '.' . $foreignKey) |
|
150 | - ->whereExp($model . '.' . $localKey, '=' . $relation . '.' . $foreignKey) |
|
151 | - ->when($softDelete, function ($query) use ($softDelete, $relation) { |
|
152 | - $query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null); |
|
149 | + ->field($relation.'.'.$foreignKey) |
|
150 | + ->whereExp($model.'.'.$localKey, '='.$relation.'.'.$foreignKey) |
|
151 | + ->when($softDelete, function($query) use ($softDelete, $relation) { |
|
152 | + $query->where($relation.strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null); |
|
153 | 153 | }); |
154 | 154 | }); |
155 | 155 | } |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | return $this->parent->db() |
178 | 178 | ->alias($model) |
179 | 179 | ->field($fields) |
180 | - ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $this->joinType) |
|
181 | - ->when($softDelete, function ($query) use ($softDelete, $relation) { |
|
182 | - $query->where($relation . strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null); |
|
180 | + ->join([$table => $relation], $model.'.'.$this->localKey.'='.$relation.'.'.$this->foreignKey, $this->joinType) |
|
181 | + ->when($softDelete, function($query) use ($softDelete, $relation) { |
|
182 | + $query->where($relation.strstr($softDelete[0], '.'), '=' == $softDelete[1][0] ? $softDelete[1][1] : null); |
|
183 | 183 | }) |
184 | 184 | ->where($where); |
185 | 185 | } |