@@ -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; |