@@ -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 | |
@@ -126,15 +126,15 @@ discard block |
||
126 | 126 | $name = App::parseName(substr($method, 5)); |
127 | 127 | array_unshift($args, $name); |
128 | 128 | return call_user_func_array([$this, 'where'], $args); |
129 | - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { |
|
129 | + } elseif ($this->model && method_exists($this->model, 'scope'.$method)) { |
|
130 | 130 | // 动态调用命名范围 |
131 | - $method = 'scope' . $method; |
|
131 | + $method = 'scope'.$method; |
|
132 | 132 | array_unshift($args, $this); |
133 | 133 | |
134 | 134 | call_user_func_array([$this->model, $method], $args); |
135 | 135 | return $this; |
136 | 136 | } else { |
137 | - throw new Exception('method not exist:' . static::class . '->' . $method); |
|
137 | + throw new Exception('method not exist:'.static::class.'->'.$method); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | $name = $name ?: $this->name; |
210 | 210 | |
211 | - return $this->prefix . App::parseName($name); |
|
211 | + return $this->prefix.App::parseName($name); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | $prefix = $prefix ?: $tableName; |
434 | 434 | foreach ($field as $key => &$val) { |
435 | 435 | if (is_numeric($key) && $alias) { |
436 | - $field[$prefix . '.' . $val] = $alias . $val; |
|
436 | + $field[$prefix.'.'.$val] = $alias.$val; |
|
437 | 437 | unset($field[$key]); |
438 | 438 | } elseif (is_numeric($key)) { |
439 | - $val = $prefix . '.' . $val; |
|
439 | + $val = $prefix.'.'.$val; |
|
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | // 延迟写入 |
491 | 491 | $condition = $this->options['where'] ?? []; |
492 | 492 | |
493 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
493 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
494 | 494 | $step = $this->connection->lazyWrite($op, $guid, $step, $lazyTime); |
495 | 495 | |
496 | 496 | if (false === $step) { |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | */ |
559 | 559 | public function limit(int $offset, int $length = null) |
560 | 560 | { |
561 | - $this->options['limit'] = $offset . ($length ? ',' . $length : ''); |
|
561 | + $this->options['limit'] = $offset.($length ? ','.$length : ''); |
|
562 | 562 | |
563 | 563 | return $this; |
564 | 564 | } |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | throw new Exception('not support type'); |
694 | 694 | } |
695 | 695 | |
696 | - $results = $this->when($lastId, function ($query) use ($key, $sort, $lastId) { |
|
696 | + $results = $this->when($lastId, function($query) use ($key, $sort, $lastId) { |
|
697 | 697 | $query->where($key, 'asc' == $sort ? '>' : '<', $lastId); |
698 | 698 | }) |
699 | 699 | ->limit($listRows) |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | $this->order($key, $sort); |
731 | 731 | } |
732 | 732 | |
733 | - $result = $this->when($lastId, function ($query) use ($key, $sort, $lastId) { |
|
733 | + $result = $this->when($lastId, function($query) use ($key, $sort, $lastId) { |
|
734 | 734 | $query->where($key, 'asc' == $sort ? '>' : '<', $lastId); |
735 | 735 | })->limit($limit)->select(); |
736 | 736 | |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | |
852 | 852 | if (is_string($field)) { |
853 | 853 | if (!empty($this->options['via'])) { |
854 | - $field = $this->options['via'] . '.' . $field; |
|
854 | + $field = $this->options['via'].'.'.$field; |
|
855 | 855 | } |
856 | 856 | if (strpos($field, ',')) { |
857 | 857 | $field = array_map('trim', explode(',', $field)); |
@@ -861,9 +861,9 @@ discard block |
||
861 | 861 | } elseif (!empty($this->options['via'])) { |
862 | 862 | foreach ($field as $key => $val) { |
863 | 863 | if (is_numeric($key)) { |
864 | - $field[$key] = $this->options['via'] . '.' . $val; |
|
864 | + $field[$key] = $this->options['via'].'.'.$val; |
|
865 | 865 | } else { |
866 | - $field[$this->options['via'] . '.' . $key] = $val; |
|
866 | + $field[$this->options['via'].'.'.$key] = $val; |
|
867 | 867 | unset($field[$key]); |
868 | 868 | } |
869 | 869 | } |
@@ -1537,7 +1537,7 @@ discard block |
||
1537 | 1537 | */ |
1538 | 1538 | public function buildSql(bool $sub = true): string |
1539 | 1539 | { |
1540 | - return $sub ? '( ' . $this->fetchSql()->select() . ' )' : $this->fetchSql()->select(); |
|
1540 | + return $sub ? '( '.$this->fetchSql()->select().' )' : $this->fetchSql()->select(); |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | /** |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | $page = $page > 0 ? $page : 1; |
1594 | 1594 | $listRows = $listRows ?: (is_numeric($options['limit']) ? $options['limit'] : 20); |
1595 | 1595 | $offset = $listRows * ($page - 1); |
1596 | - $options['limit'] = $offset . ',' . $listRows; |
|
1596 | + $options['limit'] = $offset.','.$listRows; |
|
1597 | 1597 | } |
1598 | 1598 | |
1599 | 1599 | $this->options = $options; |
@@ -1657,7 +1657,7 @@ discard block |
||
1657 | 1657 | $alias = $this->options['alias'][$table]; |
1658 | 1658 | } |
1659 | 1659 | |
1660 | - $key = isset($alias) ? $alias . '.' . $pk : $pk; |
|
1660 | + $key = isset($alias) ? $alias.'.'.$pk : $pk; |
|
1661 | 1661 | // 根据主键查询 |
1662 | 1662 | if (is_array($data)) { |
1663 | 1663 | $this->where($key, 'in', $data); |