@@ -8,7 +8,7 @@ |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db; |
14 | 14 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: 麦当苗儿 <[email protected]> <http://zjzit.cn> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db\exception; |
14 | 14 |
@@ -8,7 +8,7 @@ |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: 麦当苗儿 <[email protected]> <http://zjzit.cn> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db\exception; |
14 | 14 |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | foreach ($hosts as $i => $host) { |
57 | 57 | $port = $ports[$i] ?? $ports[0]; |
58 | 58 | $this->options['timeout'] > 0 ? |
59 | - $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, $this->options['timeout']) : |
|
60 | - $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); |
|
59 | + $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, $this->options['timeout']) : $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); |
|
61 | 60 | } |
62 | 61 | } |
63 | 62 | |
@@ -174,8 +173,7 @@ discard block |
||
174 | 173 | $key = $this->getCacheKey($name); |
175 | 174 | |
176 | 175 | return false === $ttl ? |
177 | - $this->handler->delete($key) : |
|
178 | - $this->handler->delete($key, $ttl); |
|
176 | + $this->handler->delete($key) : $this->handler->delete($key, $ttl); |
|
179 | 177 | } |
180 | 178 | |
181 | 179 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db; |
14 | 14 | |
@@ -158,20 +158,20 @@ discard block |
||
158 | 158 | if (false !== strpos($key, '->')) { |
159 | 159 | list($key, $name) = explode('->', $key, 2); |
160 | 160 | $item = $this->parseKey($query, $key); |
161 | - $result[$item] = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key . '->' . $name, $val, $bind) . ')'; |
|
161 | + $result[$item] = 'json_set('.$item.', \'$.'.$name.'\', '.$this->parseDataBind($query, $key.'->'.$name, $val, $bind).')'; |
|
162 | 162 | } elseif (false === strpos($key, '.') && !in_array($key, $fields, true)) { |
163 | 163 | if ($options['strict']) { |
164 | - throw new Exception('fields not exists:[' . $key . ']'); |
|
164 | + throw new Exception('fields not exists:['.$key.']'); |
|
165 | 165 | } |
166 | 166 | } elseif (is_null($val)) { |
167 | 167 | $result[$item] = 'NULL'; |
168 | 168 | } elseif (is_array($val) && !empty($val)) { |
169 | 169 | switch (strtoupper($val[0])) { |
170 | 170 | case 'INC': |
171 | - $result[$item] = $item . ' + ' . floatval($val[1]); |
|
171 | + $result[$item] = $item.' + '.floatval($val[1]); |
|
172 | 172 | break; |
173 | 173 | case 'DEC': |
174 | - $result[$item] = $item . ' - ' . floatval($val[1]); |
|
174 | + $result[$item] = $item.' - '.floatval($val[1]); |
|
175 | 175 | break; |
176 | 176 | } |
177 | 177 | } elseif (is_scalar($val)) { |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | $name = $query->bindValue($data, $bind[$key] ?? PDO::PARAM_STR); |
202 | 202 | |
203 | - return ':' . $name; |
|
203 | + return ':'.$name; |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | protected function parseExtra(Query $query, string $extra): string |
227 | 227 | { |
228 | - return preg_match('/^[\w]+$/i', $extra) ? ' ' . strtoupper($extra) : ''; |
|
228 | + return preg_match('/^[\w]+$/i', $extra) ? ' '.strtoupper($extra) : ''; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | if ($field instanceof Raw) { |
246 | 246 | $array[] = $field->getValue(); |
247 | 247 | } elseif (!is_numeric($key)) { |
248 | - $array[] = $this->parseKey($query, $key) . ' AS ' . $this->parseKey($query, $field, true); |
|
248 | + $array[] = $this->parseKey($query, $key).' AS '.$this->parseKey($query, $field, true); |
|
249 | 249 | } else { |
250 | 250 | $array[] = $this->parseKey($query, $field); |
251 | 251 | } |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | if ($table instanceof Raw) { |
276 | 276 | $item[] = $table->getValue(); |
277 | 277 | } elseif (!is_numeric($key)) { |
278 | - $item[] = $this->parseKey($query, $key) . ' ' . $this->parseKey($query, $table); |
|
278 | + $item[] = $this->parseKey($query, $key).' '.$this->parseKey($query, $table); |
|
279 | 279 | } elseif (isset($options['alias'][$table])) { |
280 | - $item[] = $this->parseKey($query, $table) . ' ' . $this->parseKey($query, $options['alias'][$table]); |
|
280 | + $item[] = $this->parseKey($query, $table).' '.$this->parseKey($query, $options['alias'][$table]); |
|
281 | 281 | } else { |
282 | 282 | $item[] = $this->parseKey($query, $table); |
283 | 283 | } |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | list($field, $condition) = $options['soft_delete']; |
304 | 304 | |
305 | 305 | $binds = $query->getFieldsBindType(); |
306 | - $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; |
|
307 | - $whereStr = $whereStr . $this->parseWhereItem($query, $field, $condition, $binds); |
|
306 | + $whereStr = $whereStr ? '( '.$whereStr.' ) AND ' : ''; |
|
307 | + $whereStr = $whereStr.$this->parseWhereItem($query, $field, $condition, $binds); |
|
308 | 308 | } |
309 | 309 | |
310 | - return empty($whereStr) ? '' : ' WHERE ' . $whereStr; |
|
310 | + return empty($whereStr) ? '' : ' WHERE '.$whereStr; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -350,17 +350,17 @@ discard block |
||
350 | 350 | $where = []; |
351 | 351 | foreach ($val as $value) { |
352 | 352 | if ($value instanceof Raw) { |
353 | - $where[] = ' ' . $logic . ' ( ' . $value->getValue() . ' )'; |
|
353 | + $where[] = ' '.$logic.' ( '.$value->getValue().' )'; |
|
354 | 354 | continue; |
355 | 355 | } |
356 | 356 | |
357 | 357 | if (is_array($value)) { |
358 | 358 | if (key($value) !== 0) { |
359 | - throw new Exception('where express error:' . var_export($value, true)); |
|
359 | + throw new Exception('where express error:'.var_export($value, true)); |
|
360 | 360 | } |
361 | 361 | $field = array_shift($value); |
362 | 362 | } elseif (!($value instanceof Closure)) { |
363 | - throw new Exception('where express error:' . var_export($value, true)); |
|
363 | + throw new Exception('where express error:'.var_export($value, true)); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | if ($value instanceof Closure) { |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | } elseif (is_array($field)) { |
370 | 370 | $where[] = $this->parseMultiWhereField($query, $value, $field, $logic, $binds); |
371 | 371 | } elseif ($field instanceof Raw) { |
372 | - $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); |
|
372 | + $where[] = ' '.$logic.' '.$this->parseWhereItem($query, $field, $value, $binds); |
|
373 | 373 | } elseif (strpos($field, '|')) { |
374 | 374 | $where[] = $this->parseFieldsOr($query, $value, $field, $logic, $binds); |
375 | 375 | } elseif (strpos($field, '&')) { |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } else { |
378 | 378 | // 对字段使用表达式查询 |
379 | 379 | $field = is_string($field) ? $field : ''; |
380 | - $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); |
|
380 | + $where[] = ' '.$logic.' '.$this->parseWhereItem($query, $field, $value, $binds); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | $item[] = $this->parseWhereItem($query, $k, $value, $binds); |
403 | 403 | } |
404 | 404 | |
405 | - return ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )'; |
|
405 | + return ' '.$logic.' ( '.implode(' AND ', $item).' )'; |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | $item[] = $this->parseWhereItem($query, $k, $value, $binds); |
424 | 424 | } |
425 | 425 | |
426 | - return ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )'; |
|
426 | + return ' '.$logic.' ( '.implode(' OR ', $item).' )'; |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $whereClause = $this->buildWhere($query, $newQuery->getOptions('where') ?: []); |
442 | 442 | |
443 | 443 | if (!empty($whereClause)) { |
444 | - $where = ' ' . $logic . ' ( ' . $whereClause . ' )'; |
|
444 | + $where = ' '.$logic.' ( '.$whereClause.' )'; |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | return $where ?? ''; |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $where[] = $this->parseWhereItem($query, array_shift($item), $item, $binds); |
467 | 467 | } |
468 | 468 | |
469 | - return ' ' . $logic . ' ( ' . implode(' AND ', $where) . ' )'; |
|
469 | + return ' '.$logic.' ( '.implode(' AND ', $where).' )'; |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | /** |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | |
488 | 488 | // 检测操作符 |
489 | 489 | if (!is_string($exp)) { |
490 | - throw new Exception('where express error:' . var_export($exp, true)); |
|
490 | + throw new Exception('where express error:'.var_export($exp, true)); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | $exp = strtoupper($exp); |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | if (is_string($value) && 0 === strpos($value, ':') && $query->isBind(substr($value, 1))) { |
513 | 513 | } else { |
514 | 514 | $name = $query->bindValue($value, $bindType); |
515 | - $value = ':' . $name; |
|
515 | + $value = ':'.$name; |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
526 | - throw new Exception('where express error:' . $exp); |
|
526 | + throw new Exception('where express error:'.$exp); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -545,12 +545,12 @@ discard block |
||
545 | 545 | $array = []; |
546 | 546 | foreach ($value as $item) { |
547 | 547 | $name = $query->bindValue($item, PDO::PARAM_STR); |
548 | - $array[] = $key . ' ' . $exp . ' :' . $name; |
|
548 | + $array[] = $key.' '.$exp.' :'.$name; |
|
549 | 549 | } |
550 | 550 | |
551 | - $whereStr = '(' . implode(' ' . strtoupper($logic) . ' ', $array) . ')'; |
|
551 | + $whereStr = '('.implode(' '.strtoupper($logic).' ', $array).')'; |
|
552 | 552 | } else { |
553 | - $whereStr = $key . ' ' . $exp . ' ' . $value; |
|
553 | + $whereStr = $key.' '.$exp.' '.$value; |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | return $whereStr; |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | protected function parseExp(Query $query, string $key, string $exp, Raw $value, string $field, int $bindType): string |
571 | 571 | { |
572 | 572 | // 表达式查询 |
573 | - return '( ' . $key . ' ' . $value->getValue() . ' )'; |
|
573 | + return '( '.$key.' '.$value->getValue().' )'; |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | list($op, $field) = $value; |
591 | 591 | |
592 | 592 | if (!in_array(trim($op), ['=', '<>', '>', '>=', '<', '<='])) { |
593 | - throw new Exception('where express error:' . var_export($value, true)); |
|
593 | + throw new Exception('where express error:'.var_export($value, true)); |
|
594 | 594 | } |
595 | 595 | |
596 | - return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field, true) . ' )'; |
|
596 | + return '( '.$key.' '.$op.' '.$this->parseKey($query, $field, true).' )'; |
|
597 | 597 | } |
598 | 598 | |
599 | 599 | /** |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string |
611 | 611 | { |
612 | 612 | // NULL 查询 |
613 | - return $key . ' IS ' . $exp; |
|
613 | + return $key.' IS '.$exp; |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | /** |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | $min = $query->bindValue($data[0], $bindType); |
633 | 633 | $max = $query->bindValue($data[1], $bindType); |
634 | 634 | |
635 | - return $key . ' ' . $exp . ' :' . $min . ' AND :' . $max . ' '; |
|
635 | + return $key.' '.$exp.' :'.$min.' AND :'.$max.' '; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -654,10 +654,10 @@ discard block |
||
654 | 654 | } elseif ($value instanceof Raw) { |
655 | 655 | $value = $value->getValue(); |
656 | 656 | } else { |
657 | - throw new Exception('where express error:' . $value); |
|
657 | + throw new Exception('where express error:'.$value); |
|
658 | 658 | } |
659 | 659 | |
660 | - return $exp . ' ( ' . $value . ' )'; |
|
660 | + return $exp.' ( '.$value.' )'; |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | /** |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | */ |
674 | 674 | protected function parseTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string |
675 | 675 | { |
676 | - return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType); |
|
676 | + return $key.' '.substr($exp, 0, 2).' '.$this->parseDateTime($query, $value, $field, $bindType); |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | /** |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | protected function parseCompare(Query $query, string $key, string $exp, $value, $field, int $bindType): string |
691 | 691 | { |
692 | 692 | if (is_array($value)) { |
693 | - throw new Exception('where express error:' . $exp . var_export($value, true)); |
|
693 | + throw new Exception('where express error:'.$exp.var_export($value, true)); |
|
694 | 694 | } |
695 | 695 | |
696 | 696 | // 比较运算 |
@@ -699,10 +699,10 @@ discard block |
||
699 | 699 | } |
700 | 700 | |
701 | 701 | if ('=' == $exp && is_null($value)) { |
702 | - return $key . ' IS NULL'; |
|
702 | + return $key.' IS NULL'; |
|
703 | 703 | } |
704 | 704 | |
705 | - return $key . ' ' . $exp . ' ' . $value; |
|
705 | + return $key.' '.$exp.' '.$value; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | $value = explode(',', $value); |
723 | 723 | } |
724 | 724 | |
725 | - return $key . ' ' . substr($exp, 0, -4) |
|
725 | + return $key.' '.substr($exp, 0, -4) |
|
726 | 726 | . $this->parseDateTime($query, $value[0], $field, $bindType) |
727 | 727 | . ' AND ' |
728 | 728 | . $this->parseDateTime($query, $value[1], $field, $bindType); |
@@ -753,18 +753,18 @@ discard block |
||
753 | 753 | |
754 | 754 | foreach ($value as $v) { |
755 | 755 | $name = $query->bindValue($v, $bindType); |
756 | - $array[] = ':' . $name; |
|
756 | + $array[] = ':'.$name; |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | if (count($array) == 1) { |
760 | - return $key . ('IN' == $exp ? ' = ' : ' <> ') . $array[0]; |
|
760 | + return $key.('IN' == $exp ? ' = ' : ' <> ').$array[0]; |
|
761 | 761 | } else { |
762 | 762 | $zone = implode(',', $array); |
763 | 763 | $value = empty($zone) ? "''" : $zone; |
764 | 764 | } |
765 | 765 | } |
766 | 766 | |
767 | - return $key . ' ' . $exp . ' (' . $value . ')'; |
|
767 | + return $key.' '.$exp.' ('.$value.')'; |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | /** |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | |
828 | 828 | $name = $query->bindValue($value, $bindType); |
829 | 829 | |
830 | - return ':' . $name; |
|
830 | + return ':'.$name; |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | /** |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | */ |
840 | 840 | protected function parseLimit(Query $query, string $limit): string |
841 | 841 | { |
842 | - return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; |
|
842 | + return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT '.$limit.' ' : ''; |
|
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
@@ -859,14 +859,14 @@ discard block |
||
859 | 859 | if (strpos($on, '=')) { |
860 | 860 | list($val1, $val2) = explode('=', $on, 2); |
861 | 861 | |
862 | - $condition = $this->parseKey($query, $val1) . '=' . $this->parseKey($query, $val2); |
|
862 | + $condition = $this->parseKey($query, $val1).'='.$this->parseKey($query, $val2); |
|
863 | 863 | } else { |
864 | 864 | $condition = $on; |
865 | 865 | } |
866 | 866 | |
867 | 867 | $table = $this->parseTable($query, $table); |
868 | 868 | |
869 | - $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . $condition; |
|
869 | + $joinStr .= ' '.$type.' JOIN '.$table.' ON '.$condition; |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | return $joinStr; |
@@ -891,22 +891,22 @@ discard block |
||
891 | 891 | $array[] = $this->parseRand($query); |
892 | 892 | } elseif (is_string($val)) { |
893 | 893 | if (is_numeric($key)) { |
894 | - list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); |
|
894 | + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val.' '); |
|
895 | 895 | } else { |
896 | 896 | $sort = $val; |
897 | 897 | } |
898 | 898 | |
899 | 899 | if (preg_match('/^[\w\.]+$/', $key)) { |
900 | 900 | $sort = strtoupper($sort); |
901 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
902 | - $array[] = $this->parseKey($query, $key, true) . $sort; |
|
901 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
902 | + $array[] = $this->parseKey($query, $key, true).$sort; |
|
903 | 903 | } else { |
904 | - throw new Exception('order express error:' . $key); |
|
904 | + throw new Exception('order express error:'.$key); |
|
905 | 905 | } |
906 | 906 | } |
907 | 907 | } |
908 | 908 | |
909 | - return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); |
|
909 | + return empty($array) ? '' : ' ORDER BY '.implode(',', $array); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -938,14 +938,14 @@ discard block |
||
938 | 938 | } |
939 | 939 | |
940 | 940 | $sort = strtoupper($sort); |
941 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
941 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
942 | 942 | $bind = $query->getFieldsBindType(); |
943 | 943 | |
944 | 944 | foreach ($val as $item) { |
945 | 945 | $val[] = $this->parseDataBind($query, $key, $item, $bind); |
946 | 946 | } |
947 | 947 | |
948 | - return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort; |
|
948 | + return 'field('.$this->parseKey($query, $key, true).','.implode(',', $val).')'.$sort; |
|
949 | 949 | } |
950 | 950 | |
951 | 951 | /** |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | $val[] = $this->parseKey($query, $key); |
971 | 971 | } |
972 | 972 | |
973 | - return ' GROUP BY ' . implode(',', $val); |
|
973 | + return ' GROUP BY '.implode(',', $val); |
|
974 | 974 | } |
975 | 975 | |
976 | 976 | /** |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | */ |
983 | 983 | protected function parseHaving(Query $query, string $having): string |
984 | 984 | { |
985 | - return !empty($having) ? ' HAVING ' . $having : ''; |
|
985 | + return !empty($having) ? ' HAVING '.$having : ''; |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | /** |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | $comment = strstr($comment, '*/', true); |
999 | 999 | } |
1000 | 1000 | |
1001 | - return !empty($comment) ? ' /* ' . $comment . ' */' : ''; |
|
1001 | + return !empty($comment) ? ' /* '.$comment.' */' : ''; |
|
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | /** |
@@ -1031,13 +1031,13 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | foreach ($union as $u) { |
1033 | 1033 | if ($u instanceof Closure) { |
1034 | - $sql[] = $type . ' ' . $this->parseClosure($query, $u); |
|
1034 | + $sql[] = $type.' '.$this->parseClosure($query, $u); |
|
1035 | 1035 | } elseif (is_string($u)) { |
1036 | - $sql[] = $type . ' ( ' . $u . ' )'; |
|
1036 | + $sql[] = $type.' ( '.$u.' )'; |
|
1037 | 1037 | } |
1038 | 1038 | } |
1039 | 1039 | |
1040 | - return ' ' . implode(' ', $sql); |
|
1040 | + return ' '.implode(' ', $sql); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | if (is_string($lock) && !empty($lock)) { |
1077 | - return ' ' . trim($lock) . ' '; |
|
1077 | + return ' '.trim($lock).' '; |
|
1078 | 1078 | } else { |
1079 | 1079 | return ''; |
1080 | 1080 | } |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | foreach ($dataSet as $k => $data) { |
1172 | 1172 | $data = $this->parseData($query, $data, $allowFields, $bind); |
1173 | 1173 | |
1174 | - $values[] = 'SELECT ' . implode(',', array_values($data)); |
|
1174 | + $values[] = 'SELECT '.implode(',', array_values($data)); |
|
1175 | 1175 | |
1176 | 1176 | if (!isset($insertFields)) { |
1177 | 1177 | $insertFields = array_keys($data); |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $field = $this->parseKey($query, $field, true); |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query); |
|
1212 | + return 'INSERT INTO '.$this->parseTable($query, $table).' ('.implode(',', $fields).') '.$this->select($query); |
|
1213 | 1213 | } |
1214 | 1214 | |
1215 | 1215 | /** |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | |
1231 | 1231 | $set = []; |
1232 | 1232 | foreach ($data as $key => $val) { |
1233 | - $set[] = $key . ' = ' . $val; |
|
1233 | + $set[] = $key.' = '.$val; |
|
1234 | 1234 | } |
1235 | 1235 | |
1236 | 1236 | return str_replace( |
@@ -1264,7 +1264,7 @@ discard block |
||
1264 | 1264 | [ |
1265 | 1265 | $this->parseTable($query, $options['table']), |
1266 | 1266 | $this->parseExtra($query, $options['extra']), |
1267 | - !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', |
|
1267 | + !empty($options['using']) ? ' USING '.$this->parseTable($query, $options['using']).' ' : '', |
|
1268 | 1268 | $this->parseJoin($query, $options['join']), |
1269 | 1269 | $this->parseWhere($query, $options['where']), |
1270 | 1270 | $this->parseOrder($query, $options['order']), |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db; |
14 | 14 | |
@@ -161,15 +161,15 @@ discard block |
||
161 | 161 | $name = App::parseName(substr($method, 5)); |
162 | 162 | array_unshift($args, $name); |
163 | 163 | return call_user_func_array([$this, 'where'], $args); |
164 | - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { |
|
164 | + } elseif ($this->model && method_exists($this->model, 'scope'.$method)) { |
|
165 | 165 | // 动态调用命名范围 |
166 | - $method = 'scope' . $method; |
|
166 | + $method = 'scope'.$method; |
|
167 | 167 | array_unshift($args, $this); |
168 | 168 | |
169 | 169 | call_user_func_array([$this->model, $method], $args); |
170 | 170 | return $this; |
171 | 171 | } else { |
172 | - throw new Exception('method not exist:' . static::class . '->' . $method); |
|
172 | + throw new Exception('method not exist:'.static::class.'->'.$method); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | $name = $name ?: $this->name; |
291 | 291 | |
292 | - return $this->prefix . App::parseName($name); |
|
292 | + return $this->prefix.App::parseName($name); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | // 支持GROUP |
560 | 560 | $options = $this->getOptions(); |
561 | 561 | $subSql = $this->options($options) |
562 | - ->field('count(' . $field . ') AS think_count') |
|
562 | + ->field('count('.$field.') AS think_count') |
|
563 | 563 | ->bind($this->bind) |
564 | 564 | ->buildSql(); |
565 | 565 | |
@@ -854,10 +854,10 @@ discard block |
||
854 | 854 | $prefix = $prefix ?: $tableName; |
855 | 855 | foreach ($field as $key => &$val) { |
856 | 856 | if (is_numeric($key) && $alias) { |
857 | - $field[$prefix . '.' . $val] = $alias . $val; |
|
857 | + $field[$prefix.'.'.$val] = $alias.$val; |
|
858 | 858 | unset($field[$key]); |
859 | 859 | } elseif (is_numeric($key)) { |
860 | - $val = $prefix . '.' . $val; |
|
860 | + $val = $prefix.'.'.$val; |
|
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | // 延迟写入 |
912 | 912 | $condition = $this->options['where'] ?? []; |
913 | 913 | |
914 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
914 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
915 | 915 | $step = $this->connection->lazyWrite($op, $guid, $step, $lazyTime); |
916 | 916 | |
917 | 917 | if (false === $step) { |
@@ -970,7 +970,7 @@ discard block |
||
970 | 970 | $table = $this->getJoinTable($join, $alias); |
971 | 971 | |
972 | 972 | if (true === $field) { |
973 | - $fields = $alias . '.*'; |
|
973 | + $fields = $alias.'.*'; |
|
974 | 974 | } else { |
975 | 975 | if (is_string($field)) { |
976 | 976 | $field = explode(',', $field); |
@@ -978,17 +978,17 @@ discard block |
||
978 | 978 | |
979 | 979 | foreach ($field as $key => $val) { |
980 | 980 | if (is_numeric($key)) { |
981 | - $fields[] = $alias . '.' . $val; |
|
981 | + $fields[] = $alias.'.'.$val; |
|
982 | 982 | |
983 | - $this->options['map'][$val] = $alias . '.' . $val; |
|
983 | + $this->options['map'][$val] = $alias.'.'.$val; |
|
984 | 984 | } else { |
985 | 985 | if (preg_match('/[,=\.\'\"\(\s]/', $key)) { |
986 | 986 | $name = $key; |
987 | 987 | } else { |
988 | - $name = $alias . '.' . $key; |
|
988 | + $name = $alias.'.'.$key; |
|
989 | 989 | } |
990 | 990 | |
991 | - $fields[] = $name . ' AS ' . $val; |
|
991 | + $fields[] = $name.' AS '.$val; |
|
992 | 992 | |
993 | 993 | $this->options['map'][$val] = $name; |
994 | 994 | } |
@@ -1041,7 +1041,7 @@ discard block |
||
1041 | 1041 | foreach ($this->options['where'] as $logic => &$where) { |
1042 | 1042 | foreach ($where as $key => &$val) { |
1043 | 1043 | if (is_array($val) && !strpos($val[0], '.')) { |
1044 | - $val[0] = $via . '.' . $val[0]; |
|
1044 | + $val[0] = $via.'.'.$val[0]; |
|
1045 | 1045 | } |
1046 | 1046 | } |
1047 | 1047 | } |
@@ -1351,7 +1351,7 @@ discard block |
||
1351 | 1351 | $logic = strtoupper($logic); |
1352 | 1352 | |
1353 | 1353 | if (is_string($field) && !empty($this->options['via']) && false === strpos($field, '.')) { |
1354 | - $field = $this->options['via'] . '.' . $field; |
|
1354 | + $field = $this->options['via'].'.'.$field; |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | if ($field instanceof Raw) { |
@@ -1550,7 +1550,7 @@ discard block |
||
1550 | 1550 | */ |
1551 | 1551 | public function limit(int $offset, int $length = null) |
1552 | 1552 | { |
1553 | - $this->options['limit'] = $offset . ($length ? ',' . $length : ''); |
|
1553 | + $this->options['limit'] = $offset.($length ? ','.$length : ''); |
|
1554 | 1554 | |
1555 | 1555 | return $this; |
1556 | 1556 | } |
@@ -1746,7 +1746,7 @@ discard block |
||
1746 | 1746 | |
1747 | 1747 | if (is_string($field)) { |
1748 | 1748 | if (!empty($this->options['via'])) { |
1749 | - $field = $this->options['via'] . '.' . $field; |
|
1749 | + $field = $this->options['via'].'.'.$field; |
|
1750 | 1750 | } |
1751 | 1751 | if (strpos($field, ',')) { |
1752 | 1752 | $field = array_map('trim', explode(',', $field)); |
@@ -1756,9 +1756,9 @@ discard block |
||
1756 | 1756 | } elseif (!empty($this->options['via'])) { |
1757 | 1757 | foreach ($field as $key => $val) { |
1758 | 1758 | if (is_numeric($key)) { |
1759 | - $field[$key] = $this->options['via'] . '.' . $val; |
|
1759 | + $field[$key] = $this->options['via'].'.'.$val; |
|
1760 | 1760 | } else { |
1761 | - $field[$this->options['via'] . '.' . $key] = $val; |
|
1761 | + $field[$this->options['via'].'.'.$key] = $val; |
|
1762 | 1762 | unset($field[$key]); |
1763 | 1763 | } |
1764 | 1764 | } |
@@ -2132,7 +2132,7 @@ discard block |
||
2132 | 2132 | if ($this->model) { |
2133 | 2133 | // 检查模型类的查询范围方法 |
2134 | 2134 | foreach ($scope as $name) { |
2135 | - $method = 'scope' . trim($name); |
|
2135 | + $method = 'scope'.trim($name); |
|
2136 | 2136 | |
2137 | 2137 | if (method_exists($this->model, $method)) { |
2138 | 2138 | call_user_func_array([$this->model, $method], $args); |
@@ -2184,7 +2184,7 @@ discard block |
||
2184 | 2184 | $op = 'between'; |
2185 | 2185 | } |
2186 | 2186 | |
2187 | - return $this->parseWhereExp($logic, $field, strtolower($op) . ' time', $range, [], true); |
|
2187 | + return $this->parseWhereExp($logic, $field, strtolower($op).' time', $range, [], true); |
|
2188 | 2188 | } |
2189 | 2189 | |
2190 | 2190 | /** |
@@ -2200,7 +2200,7 @@ discard block |
||
2200 | 2200 | public function whereTimeInterval(string $field, string $start, string $interval = 'day', int $step = 1, string $logic = 'AND') |
2201 | 2201 | { |
2202 | 2202 | $startTime = strtotime($start); |
2203 | - $endTime = strtotime(($step > 0 ? '+' : '-') . abs($step) . ' ' . $interval . (abs($step) > 1 ? 's' : ''), $startTime); |
|
2203 | + $endTime = strtotime(($step > 0 ? '+' : '-').abs($step).' '.$interval.(abs($step) > 1 ? 's' : ''), $startTime); |
|
2204 | 2204 | |
2205 | 2205 | return $this->whereTime($field, 'between', $step > 0 ? [$startTime, $endTime] : [$endTime, $startTime], $logic); |
2206 | 2206 | } |
@@ -2256,7 +2256,7 @@ discard block |
||
2256 | 2256 | $year = date('Y', strtotime($year)); |
2257 | 2257 | } |
2258 | 2258 | |
2259 | - return $this->whereTimeInterval($field, $year . '-1-1', 'year', $step, $logic); |
|
2259 | + return $this->whereTimeInterval($field, $year.'-1-1', 'year', $step, $logic); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | /** |
@@ -2367,7 +2367,7 @@ discard block |
||
2367 | 2367 | */ |
2368 | 2368 | public function bindValue($value, int $type = null, string $name = null) |
2369 | 2369 | { |
2370 | - $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_'; |
|
2370 | + $name = $name ?: 'ThinkBind_'.(count($this->bind) + 1).'_'; |
|
2371 | 2371 | |
2372 | 2372 | $this->bind[$name] = [$value, $type ?: PDO::PARAM_STR]; |
2373 | 2373 | return $name; |
@@ -2401,9 +2401,9 @@ discard block |
||
2401 | 2401 | } |
2402 | 2402 | |
2403 | 2403 | if (is_numeric($key)) { |
2404 | - $sql = substr_replace($sql, ':' . $name, strpos($sql, '?'), 1); |
|
2404 | + $sql = substr_replace($sql, ':'.$name, strpos($sql, '?'), 1); |
|
2405 | 2405 | } else { |
2406 | - $sql = str_replace(':' . $key, ':' . $name, $sql); |
|
2406 | + $sql = str_replace(':'.$key, ':'.$name, $sql); |
|
2407 | 2407 | } |
2408 | 2408 | } |
2409 | 2409 | } |
@@ -2564,7 +2564,7 @@ discard block |
||
2564 | 2564 | } elseif ($this->model) { |
2565 | 2565 | // 检测搜索器 |
2566 | 2566 | $fieldName = is_numeric($key) ? $field : $key; |
2567 | - $method = 'search' . App::parseName($fieldName, 1) . 'Attr'; |
|
2567 | + $method = 'search'.App::parseName($fieldName, 1).'Attr'; |
|
2568 | 2568 | |
2569 | 2569 | if (method_exists($this->model, $method)) { |
2570 | 2570 | $this->model->$method($this, $data[$field] ?? null, $data, $prefix); |
@@ -2611,10 +2611,10 @@ discard block |
||
2611 | 2611 | ->getRelationCountQuery($closure, $aggregate, $field, $aggregateField); |
2612 | 2612 | |
2613 | 2613 | if (empty($aggregateField)) { |
2614 | - $aggregateField = App::parseName($relation) . '_' . $aggregate; |
|
2614 | + $aggregateField = App::parseName($relation).'_'.$aggregate; |
|
2615 | 2615 | } |
2616 | 2616 | |
2617 | - $this->field(['(' . $count . ')' => $aggregateField]); |
|
2617 | + $this->field(['('.$count.')' => $aggregateField]); |
|
2618 | 2618 | } |
2619 | 2619 | } |
2620 | 2620 | |
@@ -3243,11 +3243,11 @@ discard block |
||
3243 | 3243 | { |
3244 | 3244 | if (!empty($this->model)) { |
3245 | 3245 | $class = get_class($this->model); |
3246 | - throw new ModelNotFoundException('model data Not Found:' . $class, $class, $this->options); |
|
3246 | + throw new ModelNotFoundException('model data Not Found:'.$class, $class, $this->options); |
|
3247 | 3247 | } |
3248 | 3248 | |
3249 | 3249 | $table = $this->getTable(); |
3250 | - throw new DataNotFoundException('table data not Found:' . $table, $table, $this->options); |
|
3250 | + throw new DataNotFoundException('table data not Found:'.$table, $table, $this->options); |
|
3251 | 3251 | } |
3252 | 3252 | |
3253 | 3253 | /** |
@@ -3362,7 +3362,7 @@ discard block |
||
3362 | 3362 | */ |
3363 | 3363 | public function buildSql(bool $sub = true): string |
3364 | 3364 | { |
3365 | - return $sub ? '( ' . $this->fetchSql()->select() . ' )' : $this->fetchSql()->select(); |
|
3365 | + return $sub ? '( '.$this->fetchSql()->select().' )' : $this->fetchSql()->select(); |
|
3366 | 3366 | } |
3367 | 3367 | |
3368 | 3368 | /** |
@@ -3464,7 +3464,7 @@ discard block |
||
3464 | 3464 | $alias = $this->options['alias'][$table]; |
3465 | 3465 | } |
3466 | 3466 | |
3467 | - $key = isset($alias) ? $alias . '.' . $pk : $pk; |
|
3467 | + $key = isset($alias) ? $alias.'.'.$pk : $pk; |
|
3468 | 3468 | // 根据主键查询 |
3469 | 3469 | if (is_array($data)) { |
3470 | 3470 | $this->where($key, 'in', $data); |
@@ -3528,7 +3528,7 @@ discard block |
||
3528 | 3528 | $page = $page > 0 ? $page : 1; |
3529 | 3529 | $listRows = $listRows ?: (is_numeric($options['limit']) ? $options['limit'] : 20); |
3530 | 3530 | $offset = $listRows * ($page - 1); |
3531 | - $options['limit'] = $offset . ',' . $listRows; |
|
3531 | + $options['limit'] = $offset.','.$listRows; |
|
3532 | 3532 | } |
3533 | 3533 | |
3534 | 3534 | $this->options = $options; |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db; |
14 | 14 | |
@@ -449,9 +449,9 @@ discard block |
||
449 | 449 | } else { |
450 | 450 | if (true === $key) { |
451 | 451 | if (!empty($query->getOptions('key'))) { |
452 | - $key = 'think:' . $this->getConfig('database') . '.' . $query->getTable() . '|' . $query->getOptions('key'); |
|
452 | + $key = 'think:'.$this->getConfig('database').'.'.$query->getTable().'|'.$query->getOptions('key'); |
|
453 | 453 | } else { |
454 | - $key = md5($this->getConfig('database') . serialize($query->getOptions())); |
|
454 | + $key = md5($this->getConfig('database').serialize($query->getOptions())); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -475,15 +475,15 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function lazyWrite(string $type, string $guid, float $step, int $lazyTime) |
477 | 477 | { |
478 | - if (!$this->cache->has($guid . '_time')) { |
|
478 | + if (!$this->cache->has($guid.'_time')) { |
|
479 | 479 | // 计时开始 |
480 | - $this->cache->set($guid . '_time', time(), 0); |
|
480 | + $this->cache->set($guid.'_time', time(), 0); |
|
481 | 481 | $this->cache->$type($guid, $step); |
482 | - } elseif (time() > $this->cache->get($guid . '_time') + $lazyTime) { |
|
482 | + } elseif (time() > $this->cache->get($guid.'_time') + $lazyTime) { |
|
483 | 483 | // 删除缓存 |
484 | 484 | $value = $this->cache->$type($guid, $step); |
485 | 485 | $this->cache->delete($guid); |
486 | - $this->cache->delete($guid . '_time'); |
|
486 | + $this->cache->delete($guid.'_time'); |
|
487 | 487 | return 0 === $value ? false : $value; |
488 | 488 | } else { |
489 | 489 | // 更新缓存 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db; |
14 | 14 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $this->query->parseOptions(); |
63 | 63 | |
64 | - $field = $aggregate . '(' . $this->builder->parseKey($this->query, $field) . ') AS tp_' . strtolower($aggregate); |
|
64 | + $field = $aggregate.'('.$this->builder->parseKey($this->query, $field).') AS tp_'.strtolower($aggregate); |
|
65 | 65 | |
66 | 66 | return $this->value($field, 0, false); |
67 | 67 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | if ($key && '*' != $field) { |
114 | - $field = $key . ',' . $field; |
|
114 | + $field = $key.','.$field; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $field = array_map('trim', explode(',', $field)); |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | if (!empty($options['group'])) { |
422 | 422 | // 支持GROUP |
423 | 423 | $bind = $this->query->getBind(); |
424 | - $subSql = $this->query->options($options)->field('count(' . $field . ') AS think_count')->bind($bind)->buildSql(); |
|
424 | + $subSql = $this->query->options($options)->field('count('.$field.') AS think_count')->bind($bind)->buildSql(); |
|
425 | 425 | |
426 | 426 | $query = $this->query->newQuery()->table([$subSql => '_group_count_']); |
427 | 427 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | // +---------------------------------------------------------------------- |
9 | 9 | // | Author: liu21st <[email protected]> |
10 | 10 | // +---------------------------------------------------------------------- |
11 | -declare (strict_types = 1); |
|
11 | +declare(strict_types=1); |
|
12 | 12 | |
13 | 13 | namespace think\db\builder; |
14 | 14 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $set = []; |
125 | 125 | foreach ($data as $key => $val) { |
126 | - $set[] = $key . ' = ' . $val; |
|
126 | + $set[] = $key.' = '.$val; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | return str_replace( |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | foreach ($dataSet as $data) { |
169 | 169 | $data = $this->parseData($query, $data, $allowFields, $bind); |
170 | 170 | |
171 | - $values[] = '( ' . implode(',', array_values($data)) . ' )'; |
|
171 | + $values[] = '( '.implode(',', array_values($data)).' )'; |
|
172 | 172 | |
173 | 173 | if (!isset($insertFields)) { |
174 | 174 | $insertFields = array_keys($data); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | } |
212 | 212 | $set = []; |
213 | 213 | foreach ($data as $key => $val) { |
214 | - $set[] = $key . ' = ' . $val; |
|
214 | + $set[] = $key.' = '.$val; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return str_replace( |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $this->parseTable($query, $options['table']), |
248 | 248 | $this->parsePartition($query, $options['partition']), |
249 | 249 | $this->parseExtra($query, $options['extra']), |
250 | - !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', |
|
250 | + !empty($options['using']) ? ' USING '.$this->parseTable($query, $options['using']).' ' : '', |
|
251 | 251 | $this->parseJoin($query, $options['join']), |
252 | 252 | $this->parseWhere($query, $options['where']), |
253 | 253 | $this->parseOrder($query, $options['order']), |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $value = $value->getValue(); |
275 | 275 | } |
276 | 276 | |
277 | - return $key . ' ' . $exp . ' ' . $value; |
|
277 | + return $key.' '.$exp.' '.$value; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | $value = $value->getValue(); |
294 | 294 | } |
295 | 295 | |
296 | - return 'FIND_IN_SET(' . $value . ', ' . $key . ')'; |
|
296 | + return 'FIND_IN_SET('.$value.', '.$key.')'; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | if (strpos($key, '->') && false === strpos($key, '(')) { |
318 | 318 | // JSON字段支持 |
319 | 319 | list($field, $name) = explode('->', $key, 2); |
320 | - return 'json_extract(' . $this->parseKey($query, $field) . ', \'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->', '.', $name) . '\')'; |
|
320 | + return 'json_extract('.$this->parseKey($query, $field).', \'$'.(strpos($name, '[') === 0 ? '' : '.').str_replace('->', '.', $name).'\')'; |
|
321 | 321 | } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { |
322 | 322 | list($table, $key) = explode('.', $key, 2); |
323 | 323 | |
@@ -334,11 +334,11 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { |
337 | - throw new Exception('not support data:' . $key); |
|
337 | + throw new Exception('not support data:'.$key); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { |
341 | - $key = '`' . $key . '`'; |
|
341 | + $key = '`'.$key.'`'; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | if (isset($table)) { |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $table = str_replace('.', '`.`', $table); |
347 | 347 | } |
348 | 348 | |
349 | - $key = '`' . $table . '`.' . $key; |
|
349 | + $key = '`'.$table.'`.'.$key; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | return $key; |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $partition = explode(',', $partition); |
381 | 381 | } |
382 | 382 | |
383 | - return ' PARTITION (' . implode(' , ', $partition) . ') '; |
|
383 | + return ' PARTITION ('.implode(' , ', $partition).') '; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | } |
398 | 398 | |
399 | 399 | if ($duplicate instanceof Raw) { |
400 | - return ' ON DUPLICATE KEY UPDATE ' . $duplicate->getValue() . ' '; |
|
400 | + return ' ON DUPLICATE KEY UPDATE '.$duplicate->getValue().' '; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | if (is_string($duplicate)) { |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | foreach ($duplicate as $key => $val) { |
409 | 409 | if (is_numeric($key)) { |
410 | 410 | $val = $this->parseKey($query, $val); |
411 | - $updates[] = $val . ' = VALUES(' . $val . ')'; |
|
411 | + $updates[] = $val.' = VALUES('.$val.')'; |
|
412 | 412 | } elseif ($val instanceof Raw) { |
413 | - $updates[] = $this->parseKey($query, $key) . " = " . $val->getValue(); |
|
413 | + $updates[] = $this->parseKey($query, $key)." = ".$val->getValue(); |
|
414 | 414 | } else { |
415 | 415 | $name = $query->bindValue($val, $query->getFieldBindType($key)); |
416 | - $updates[] = $this->parseKey($query, $key) . " = :" . $name; |
|
416 | + $updates[] = $this->parseKey($query, $key)." = :".$name; |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | - return ' ON DUPLICATE KEY UPDATE ' . implode(' , ', $updates) . ' '; |
|
420 | + return ' ON DUPLICATE KEY UPDATE '.implode(' , ', $updates).' '; |
|
421 | 421 | } |
422 | 422 | } |