@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | $name = Loader::parseName(substr($method, 5)); |
182 | 182 | array_unshift($args, $name); |
183 | 183 | return call_user_func_array([$this, 'where'], $args); |
184 | - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { |
|
184 | + } elseif ($this->model && method_exists($this->model, 'scope'.$method)) { |
|
185 | 185 | // 动态调用命名范围 |
186 | - $method = 'scope' . $method; |
|
186 | + $method = 'scope'.$method; |
|
187 | 187 | array_unshift($args, $this); |
188 | 188 | |
189 | 189 | call_user_func_array([$this->model, $method], $args); |
190 | 190 | return $this; |
191 | 191 | } else { |
192 | - throw new Exception('method not exist:' . ($this->model ? get_class($this->model) : static::class) . '->' . $method); |
|
192 | + throw new Exception('method not exist:'.($this->model ? get_class($this->model) : static::class).'->'.$method); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | |
309 | 309 | $name = $name ?: $this->name; |
310 | 310 | |
311 | - return $this->prefix . Loader::parseName($name); |
|
311 | + return $this->prefix.Loader::parseName($name); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | $seq = (ord($value{0}) % $rule['num']) + 1; |
581 | 581 | } |
582 | 582 | } |
583 | - return $this->getTable() . '_' . $seq; |
|
583 | + return $this->getTable().'_'.$seq; |
|
584 | 584 | } |
585 | 585 | // 当设置的分表字段不在查询条件或者数据中 |
586 | 586 | // 进行联合查询,必须设定 partition['num'] |
587 | 587 | $tableName = []; |
588 | 588 | for ($i = 0; $i < $rule['num']; $i++) { |
589 | - $tableName[] = 'SELECT * FROM ' . $this->getTable() . '_' . ($i + 1); |
|
589 | + $tableName[] = 'SELECT * FROM '.$this->getTable().'_'.($i + 1); |
|
590 | 590 | } |
591 | 591 | |
592 | - return ['( ' . implode(" UNION ", $tableName) . ' )' => $this->name]; |
|
592 | + return ['( '.implode(" UNION ", $tableName).' )' => $this->name]; |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | /** |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | // 支持GROUP |
656 | 656 | $options = $this->getOptions(); |
657 | 657 | $subSql = $this->options($options) |
658 | - ->field('count(' . $field . ') AS think_count') |
|
658 | + ->field('count('.$field.') AS think_count') |
|
659 | 659 | ->bind($this->bind) |
660 | 660 | ->buildSql(); |
661 | 661 | |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | |
759 | 759 | if ($lazyTime > 0) { |
760 | 760 | // 延迟写入 |
761 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
761 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
762 | 762 | $step = $this->lazyWrite('inc', $guid, $step, $lazyTime); |
763 | 763 | |
764 | 764 | if (false === $step) { |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | |
792 | 792 | if ($lazyTime > 0) { |
793 | 793 | // 延迟写入 |
794 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
794 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
795 | 795 | $step = $this->lazyWrite('dec', $guid, $step, $lazyTime); |
796 | 796 | |
797 | 797 | if (false === $step) { |
@@ -822,15 +822,15 @@ discard block |
||
822 | 822 | { |
823 | 823 | $cache = Container::get('cache'); |
824 | 824 | |
825 | - if (!$cache->has($guid . '_time')) { |
|
825 | + if (!$cache->has($guid.'_time')) { |
|
826 | 826 | // 计时开始 |
827 | - $cache->set($guid . '_time', time(), 0); |
|
827 | + $cache->set($guid.'_time', time(), 0); |
|
828 | 828 | $cache->$type($guid, $step); |
829 | - } elseif (time() > $cache->get($guid . '_time') + $lazyTime) { |
|
829 | + } elseif (time() > $cache->get($guid.'_time') + $lazyTime) { |
|
830 | 830 | // 删除缓存 |
831 | 831 | $value = $cache->$type($guid, $step); |
832 | 832 | $cache->rm($guid); |
833 | - $cache->rm($guid . '_time'); |
|
833 | + $cache->rm($guid.'_time'); |
|
834 | 834 | return 0 === $value ? false : $value; |
835 | 835 | } else { |
836 | 836 | // 更新缓存 |
@@ -1029,10 +1029,10 @@ discard block |
||
1029 | 1029 | $prefix = $prefix ?: $tableName; |
1030 | 1030 | foreach ($field as $key => &$val) { |
1031 | 1031 | if (is_numeric($key) && $alias) { |
1032 | - $field[$prefix . '.' . $val] = $alias . $val; |
|
1032 | + $field[$prefix.'.'.$val] = $alias.$val; |
|
1033 | 1033 | unset($field[$key]); |
1034 | 1034 | } elseif (is_numeric($key)) { |
1035 | - $val = $prefix . '.' . $val; |
|
1035 | + $val = $prefix.'.'.$val; |
|
1036 | 1036 | } |
1037 | 1037 | } |
1038 | 1038 | } |
@@ -1159,7 +1159,7 @@ discard block |
||
1159 | 1159 | $table = $this->getJoinTable($join, $alias); |
1160 | 1160 | |
1161 | 1161 | if (true === $field) { |
1162 | - $fields = $alias . '.*'; |
|
1162 | + $fields = $alias.'.*'; |
|
1163 | 1163 | } else { |
1164 | 1164 | if (is_string($field)) { |
1165 | 1165 | $field = explode(',', $field); |
@@ -1167,17 +1167,17 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | foreach ($field as $key => $val) { |
1169 | 1169 | if (is_numeric($key)) { |
1170 | - $fields[] = $alias . '.' . $val; |
|
1170 | + $fields[] = $alias.'.'.$val; |
|
1171 | 1171 | |
1172 | - $this->options['map'][$val] = $alias . '.' . $val; |
|
1172 | + $this->options['map'][$val] = $alias.'.'.$val; |
|
1173 | 1173 | } else { |
1174 | 1174 | if (preg_match('/[,=\.\'\"\(\s]/', $key)) { |
1175 | 1175 | $name = $key; |
1176 | 1176 | } else { |
1177 | - $name = $alias . '.' . $key; |
|
1177 | + $name = $alias.'.'.$key; |
|
1178 | 1178 | } |
1179 | 1179 | |
1180 | - $fields[] = $name . ' AS ' . $val; |
|
1180 | + $fields[] = $name.' AS '.$val; |
|
1181 | 1181 | |
1182 | 1182 | $this->options['map'][$val] = $name; |
1183 | 1183 | } |
@@ -1490,9 +1490,9 @@ discard block |
||
1490 | 1490 | } |
1491 | 1491 | |
1492 | 1492 | if (is_numeric($key)) { |
1493 | - $sql = substr_replace($sql, ':' . $name, strpos($sql, '?'), 1); |
|
1493 | + $sql = substr_replace($sql, ':'.$name, strpos($sql, '?'), 1); |
|
1494 | 1494 | } else { |
1495 | - $sql = str_replace(':' . $key, ':' . $name, $sql); |
|
1495 | + $sql = str_replace(':'.$key, ':'.$name, $sql); |
|
1496 | 1496 | } |
1497 | 1497 | } |
1498 | 1498 | } |
@@ -1536,7 +1536,7 @@ discard block |
||
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | if (is_string($field) && !empty($this->options['via']) && false === strpos($field, '.')) { |
1539 | - $field = $this->options['via'] . '.' . $field; |
|
1539 | + $field = $this->options['via'].'.'.$field; |
|
1540 | 1540 | } |
1541 | 1541 | |
1542 | 1542 | if ($field instanceof Expression) { |
@@ -1720,7 +1720,7 @@ discard block |
||
1720 | 1720 | list($offset, $length) = explode(',', $offset); |
1721 | 1721 | } |
1722 | 1722 | |
1723 | - $this->options['limit'] = intval($offset) . ($length ? ',' . intval($length) : ''); |
|
1723 | + $this->options['limit'] = intval($offset).($length ? ','.intval($length) : ''); |
|
1724 | 1724 | |
1725 | 1725 | return $this; |
1726 | 1726 | } |
@@ -1777,7 +1777,7 @@ discard block |
||
1777 | 1777 | } |
1778 | 1778 | |
1779 | 1779 | /** @var Paginator $class */ |
1780 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']); |
|
1780 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\'.ucwords($config['type']); |
|
1781 | 1781 | $page = isset($config['page']) ? (int) $config['page'] : call_user_func([ |
1782 | 1782 | $class, |
1783 | 1783 | 'getCurrentPage', |
@@ -1887,7 +1887,7 @@ discard block |
||
1887 | 1887 | |
1888 | 1888 | if (is_string($field)) { |
1889 | 1889 | if (!empty($this->options['via'])) { |
1890 | - $field = $this->options['via'] . '.' . $field; |
|
1890 | + $field = $this->options['via'].'.'.$field; |
|
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | if (strpos($field, ',')) { |
@@ -1898,9 +1898,9 @@ discard block |
||
1898 | 1898 | } elseif (!empty($this->options['via'])) { |
1899 | 1899 | foreach ($field as $key => $val) { |
1900 | 1900 | if (is_numeric($key)) { |
1901 | - $field[$key] = $this->options['via'] . '.' . $val; |
|
1901 | + $field[$key] = $this->options['via'].'.'.$val; |
|
1902 | 1902 | } else { |
1903 | - $field[$this->options['via'] . '.' . $key] = $val; |
|
1903 | + $field[$this->options['via'].'.'.$key] = $val; |
|
1904 | 1904 | unset($field[$key]); |
1905 | 1905 | } |
1906 | 1906 | } |
@@ -2312,7 +2312,7 @@ discard block |
||
2312 | 2312 | if ($this->model) { |
2313 | 2313 | // 检查模型类的查询范围方法 |
2314 | 2314 | foreach ($scope as $name) { |
2315 | - $method = 'scope' . trim($name); |
|
2315 | + $method = 'scope'.trim($name); |
|
2316 | 2316 | |
2317 | 2317 | if (method_exists($this->model, $method)) { |
2318 | 2318 | call_user_func_array([$this->model, $method], $args); |
@@ -2339,7 +2339,7 @@ discard block |
||
2339 | 2339 | } elseif ($this->model) { |
2340 | 2340 | // 检测搜索器 |
2341 | 2341 | $fieldName = is_numeric($key) ? $field : $key; |
2342 | - $method = 'search' . Loader::parseName($fieldName, 1) . 'Attr'; |
|
2342 | + $method = 'search'.Loader::parseName($fieldName, 1).'Attr'; |
|
2343 | 2343 | |
2344 | 2344 | if (method_exists($this->model, $method)) { |
2345 | 2345 | $this->model->$method($this, isset($data[$field]) ? $data[$field] : null, $data, $prefix); |
@@ -2404,7 +2404,7 @@ discard block |
||
2404 | 2404 | $op = is_array($range) ? 'between' : '>='; |
2405 | 2405 | } |
2406 | 2406 | |
2407 | - return $this->parseWhereExp($logic, $field, strtolower($op) . ' time', $range, [], true); |
|
2407 | + return $this->parseWhereExp($logic, $field, strtolower($op).' time', $range, [], true); |
|
2408 | 2408 | } |
2409 | 2409 | |
2410 | 2410 | /** |
@@ -2482,7 +2482,7 @@ discard block |
||
2482 | 2482 | if (is_array($value)) { |
2483 | 2483 | $this->bind = array_merge($this->bind, $value); |
2484 | 2484 | } else { |
2485 | - $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_' . mt_rand() . '_'; |
|
2485 | + $name = $name ?: 'ThinkBind_'.(count($this->bind) + 1).'_'.mt_rand().'_'; |
|
2486 | 2486 | |
2487 | 2487 | $this->bind[$name] = [$value, $type]; |
2488 | 2488 | return $name; |
@@ -2699,10 +2699,10 @@ discard block |
||
2699 | 2699 | $count = $this->model->$relation()->getRelationCountQuery($closure, $aggregate, $field, $aggregateField); |
2700 | 2700 | |
2701 | 2701 | if (empty($aggregateField)) { |
2702 | - $aggregateField = Loader::parseName($relation) . '_' . $aggregate; |
|
2702 | + $aggregateField = Loader::parseName($relation).'_'.$aggregate; |
|
2703 | 2703 | } |
2704 | 2704 | |
2705 | - $this->field(['(' . $count . ')' => $aggregateField]); |
|
2705 | + $this->field(['('.$count.')' => $aggregateField]); |
|
2706 | 2706 | } |
2707 | 2707 | } |
2708 | 2708 | |
@@ -3421,10 +3421,10 @@ discard block |
||
3421 | 3421 | { |
3422 | 3422 | if (!empty($this->model)) { |
3423 | 3423 | $class = get_class($this->model); |
3424 | - throw new ModelNotFoundException('model data Not Found:' . $class, $class, $options); |
|
3424 | + throw new ModelNotFoundException('model data Not Found:'.$class, $class, $options); |
|
3425 | 3425 | } |
3426 | 3426 | $table = is_array($options['table']) ? key($options['table']) : $options['table']; |
3427 | - throw new DataNotFoundException('table data not Found:' . $table, $table, $options); |
|
3427 | + throw new DataNotFoundException('table data not Found:'.$table, $table, $options); |
|
3428 | 3428 | } |
3429 | 3429 | |
3430 | 3430 | /** |
@@ -3560,7 +3560,7 @@ discard block |
||
3560 | 3560 | */ |
3561 | 3561 | public function buildSql($sub = true) |
3562 | 3562 | { |
3563 | - return $sub ? '( ' . $this->select(false) . ' )' : $this->select(false); |
|
3563 | + return $sub ? '( '.$this->select(false).' )' : $this->select(false); |
|
3564 | 3564 | } |
3565 | 3565 | |
3566 | 3566 | /** |
@@ -3631,7 +3631,7 @@ discard block |
||
3631 | 3631 | } |
3632 | 3632 | |
3633 | 3633 | if (is_string($pk)) { |
3634 | - $key = isset($alias) ? $alias . '.' . $pk : $pk; |
|
3634 | + $key = isset($alias) ? $alias.'.'.$pk : $pk; |
|
3635 | 3635 | // 根据主键查询 |
3636 | 3636 | if (is_array($data)) { |
3637 | 3637 | $where[$pk] = isset($data[$pk]) ? [$key, '=', $data[$pk]] : [$key, 'in', $data]; |
@@ -3642,7 +3642,7 @@ discard block |
||
3642 | 3642 | // 根据复合主键查询 |
3643 | 3643 | foreach ($pk as $key) { |
3644 | 3644 | if (isset($data[$key])) { |
3645 | - $attr = isset($alias) ? $alias . '.' . $key : $key; |
|
3645 | + $attr = isset($alias) ? $alias.'.'.$key : $key; |
|
3646 | 3646 | $where[$key] = [$attr, '=', $data[$key]]; |
3647 | 3647 | } else { |
3648 | 3648 | throw new Exception('miss complex primary data'); |
@@ -3718,7 +3718,7 @@ discard block |
||
3718 | 3718 | $page = $page > 0 ? $page : 1; |
3719 | 3719 | $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); |
3720 | 3720 | $offset = $listRows * ($page - 1); |
3721 | - $options['limit'] = $offset . ',' . $listRows; |
|
3721 | + $options['limit'] = $offset.','.$listRows; |
|
3722 | 3722 | } |
3723 | 3723 | |
3724 | 3724 | $this->options = $options; |