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