@@ -194,8 +194,8 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - return $this->query->alias($aggregate . '_table') |
|
| 198 | - ->whereExp($aggregate . '_table.' . $this->foreignKey, '=' . $this->parent->getTable() . '.' . $this->localKey) |
|
| 197 | + return $this->query->alias($aggregate.'_table') |
|
| 198 | + ->whereExp($aggregate.'_table.'.$this->foreignKey, '='.$this->parent->getTable().'.'.$this->localKey) |
|
| 199 | 199 | ->fetchSql() |
| 200 | 200 | ->$aggregate($field); |
| 201 | 201 | } |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | return $this->parent->db() |
| 300 | 300 | ->alias($model) |
| 301 | - ->field($model . '.*') |
|
| 302 | - ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType) |
|
| 303 | - ->group($relation . '.' . $this->foreignKey) |
|
| 304 | - ->having('count(' . $id . ')' . $operator . $count); |
|
| 301 | + ->field($model.'.*') |
|
| 302 | + ->join([$table => $relation], $model.'.'.$this->localKey.'='.$relation.'.'.$this->foreignKey, $joinType) |
|
| 303 | + ->group($relation.'.'.$this->foreignKey) |
|
| 304 | + ->having('count('.$id.')'.$operator.$count); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -325,9 +325,9 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | return $this->parent->db() |
| 327 | 327 | ->alias($model) |
| 328 | - ->group($model . '.' . $this->localKey) |
|
| 328 | + ->group($model.'.'.$this->localKey) |
|
| 329 | 329 | ->field($fields) |
| 330 | - ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey) |
|
| 330 | + ->join([$table => $relation], $model.'.'.$this->localKey.'='.$relation.'.'.$this->foreignKey) |
|
| 331 | 331 | ->where($where); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | if ($e instanceof \ParseError) { |
| 20 | - $message = 'Parse error: ' . $e->getMessage(); |
|
| 20 | + $message = 'Parse error: '.$e->getMessage(); |
|
| 21 | 21 | $severity = E_PARSE; |
| 22 | 22 | } elseif ($e instanceof \TypeError) { |
| 23 | - $message = 'Type error: ' . $e->getMessage(); |
|
| 23 | + $message = 'Type error: '.$e->getMessage(); |
|
| 24 | 24 | $severity = E_RECOVERABLE_ERROR; |
| 25 | 25 | } else { |
| 26 | - $message = 'Fatal error: ' . $e->getMessage(); |
|
| 26 | + $message = 'Fatal error: '.$e->getMessage(); |
|
| 27 | 27 | $severity = E_ERROR; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if (Container::get('app')->config('log.record_trace')) { |
| 59 | - $log .= "\r\n" . $exception->getTraceAsString(); |
|
| 59 | + $log .= "\r\n".$exception->getTraceAsString(); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | Container::get('log')->record($log, 'error'); |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | if (strpos($message, ':')) { |
| 239 | 239 | $name = strstr($message, ':', true); |
| 240 | - $message = $lang->has($name) ? $lang->get($name) . strstr($message, ':') : $message; |
|
| 240 | + $message = $lang->has($name) ? $lang->get($name).strstr($message, ':') : $message; |
|
| 241 | 241 | } elseif (strpos($message, ',')) { |
| 242 | 242 | $name = strstr($message, ',', true); |
| 243 | - $message = $lang->has($name) ? $lang->get($name) . ':' . substr(strstr($message, ','), 1) : $message; |
|
| 243 | + $message = $lang->has($name) ? $lang->get($name).':'.substr(strstr($message, ','), 1) : $message; |
|
| 244 | 244 | } elseif ($lang->has($message)) { |
| 245 | 245 | $message = $lang->get($message); |
| 246 | 246 | } |
@@ -169,15 +169,15 @@ discard block |
||
| 169 | 169 | $name = Loader::parseName(substr($method, 5)); |
| 170 | 170 | array_unshift($args, $name); |
| 171 | 171 | return call_user_func_array([$this, 'where'], $args); |
| 172 | - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { |
|
| 172 | + } elseif ($this->model && method_exists($this->model, 'scope'.$method)) { |
|
| 173 | 173 | // 动态调用命名范围 |
| 174 | - $method = 'scope' . $method; |
|
| 174 | + $method = 'scope'.$method; |
|
| 175 | 175 | array_unshift($args, $this); |
| 176 | 176 | |
| 177 | 177 | call_user_func_array([$this->model, $method], $args); |
| 178 | 178 | return $this; |
| 179 | 179 | } else { |
| 180 | - throw new Exception('method not exist:' . ($this->model ? get_class($this->model) : static::class) . '->' . $method); |
|
| 180 | + throw new Exception('method not exist:'.($this->model ? get_class($this->model) : static::class).'->'.$method); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | $name = $name ?: $this->name; |
| 298 | 298 | |
| 299 | - return $this->prefix . Loader::parseName($name); |
|
| 299 | + return $this->prefix.Loader::parseName($name); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -568,16 +568,16 @@ discard block |
||
| 568 | 568 | $seq = (ord($value{0}) % $rule['num']) + 1; |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | - return $this->getTable() . '_' . $seq; |
|
| 571 | + return $this->getTable().'_'.$seq; |
|
| 572 | 572 | } |
| 573 | 573 | // 当设置的分表字段不在查询条件或者数据中 |
| 574 | 574 | // 进行联合查询,必须设定 partition['num'] |
| 575 | 575 | $tableName = []; |
| 576 | 576 | for ($i = 0; $i < $rule['num']; $i++) { |
| 577 | - $tableName[] = 'SELECT * FROM ' . $this->getTable() . '_' . ($i + 1); |
|
| 577 | + $tableName[] = 'SELECT * FROM '.$this->getTable().'_'.($i + 1); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - return ['( ' . implode(" UNION ", $tableName) . ' )' => $this->name]; |
|
| 580 | + return ['( '.implode(" UNION ", $tableName).' )' => $this->name]; |
|
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | /** |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | // 支持GROUP |
| 644 | 644 | $options = $this->getOptions(); |
| 645 | 645 | $subSql = $this->options($options) |
| 646 | - ->field('count(' . $field . ') AS think_count') |
|
| 646 | + ->field('count('.$field.') AS think_count') |
|
| 647 | 647 | ->bind($this->bind) |
| 648 | 648 | ->buildSql(); |
| 649 | 649 | |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | if ($lazyTime > 0) { |
| 748 | 748 | // 延迟写入 |
| 749 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
| 749 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
| 750 | 750 | $step = $this->lazyWrite('inc', $guid, $step, $lazyTime); |
| 751 | 751 | |
| 752 | 752 | if (false === $step) { |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | if ($lazyTime > 0) { |
| 781 | 781 | // 延迟写入 |
| 782 | - $guid = md5($this->getTable() . '_' . $field . '_' . serialize($condition)); |
|
| 782 | + $guid = md5($this->getTable().'_'.$field.'_'.serialize($condition)); |
|
| 783 | 783 | $step = $this->lazyWrite('dec', $guid, $step, $lazyTime); |
| 784 | 784 | |
| 785 | 785 | if (false === $step) { |
@@ -810,15 +810,15 @@ discard block |
||
| 810 | 810 | { |
| 811 | 811 | $cache = Container::get('cache'); |
| 812 | 812 | |
| 813 | - if (!$cache->has($guid . '_time')) { |
|
| 813 | + if (!$cache->has($guid.'_time')) { |
|
| 814 | 814 | // 计时开始 |
| 815 | - $cache->set($guid . '_time', time(), 0); |
|
| 815 | + $cache->set($guid.'_time', time(), 0); |
|
| 816 | 816 | $cache->$type($guid, $step); |
| 817 | - } elseif (time() > $cache->get($guid . '_time') + $lazyTime) { |
|
| 817 | + } elseif (time() > $cache->get($guid.'_time') + $lazyTime) { |
|
| 818 | 818 | // 删除缓存 |
| 819 | 819 | $value = $cache->$type($guid, $step); |
| 820 | 820 | $cache->rm($guid); |
| 821 | - $cache->rm($guid . '_time'); |
|
| 821 | + $cache->rm($guid.'_time'); |
|
| 822 | 822 | return 0 === $value ? false : $value; |
| 823 | 823 | } else { |
| 824 | 824 | // 更新缓存 |
@@ -1017,10 +1017,10 @@ discard block |
||
| 1017 | 1017 | $prefix = $prefix ?: $tableName; |
| 1018 | 1018 | foreach ($field as $key => &$val) { |
| 1019 | 1019 | if (is_numeric($key) && $alias) { |
| 1020 | - $field[$prefix . '.' . $val] = $alias . $val; |
|
| 1020 | + $field[$prefix.'.'.$val] = $alias.$val; |
|
| 1021 | 1021 | unset($field[$key]); |
| 1022 | 1022 | } elseif (is_numeric($key)) { |
| 1023 | - $val = $prefix . '.' . $val; |
|
| 1023 | + $val = $prefix.'.'.$val; |
|
| 1024 | 1024 | } |
| 1025 | 1025 | } |
| 1026 | 1026 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | $table = $this->getJoinTable($join, $alias); |
| 1148 | 1148 | |
| 1149 | 1149 | if (true === $field) { |
| 1150 | - $fields = $alias . '.*'; |
|
| 1150 | + $fields = $alias.'.*'; |
|
| 1151 | 1151 | } else { |
| 1152 | 1152 | if (is_string($field)) { |
| 1153 | 1153 | $field = explode(',', $field); |
@@ -1155,17 +1155,17 @@ discard block |
||
| 1155 | 1155 | |
| 1156 | 1156 | foreach ($field as $key => $val) { |
| 1157 | 1157 | if (is_numeric($key)) { |
| 1158 | - $fields[] = $alias . '.' . $val; |
|
| 1158 | + $fields[] = $alias.'.'.$val; |
|
| 1159 | 1159 | |
| 1160 | - $this->options['map'][$val] = $alias . '.' . $val; |
|
| 1160 | + $this->options['map'][$val] = $alias.'.'.$val; |
|
| 1161 | 1161 | } else { |
| 1162 | 1162 | if (preg_match('/[,=\.\'\"\(\s]/', $key)) { |
| 1163 | 1163 | $name = $key; |
| 1164 | 1164 | } else { |
| 1165 | - $name = $alias . '.' . $key; |
|
| 1165 | + $name = $alias.'.'.$key; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | - $fields[] = $name . ' AS ' . $val; |
|
| 1168 | + $fields[] = $name.' AS '.$val; |
|
| 1169 | 1169 | |
| 1170 | 1170 | $this->options['map'][$val] = $name; |
| 1171 | 1171 | } |
@@ -1478,9 +1478,9 @@ discard block |
||
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | if (is_numeric($key)) { |
| 1481 | - $sql = substr_replace($sql, ':' . $name, strpos($sql, '?'), 1); |
|
| 1481 | + $sql = substr_replace($sql, ':'.$name, strpos($sql, '?'), 1); |
|
| 1482 | 1482 | } else { |
| 1483 | - $sql = str_replace(':' . $key, ':' . $name, $sql); |
|
| 1483 | + $sql = str_replace(':'.$key, ':'.$name, $sql); |
|
| 1484 | 1484 | } |
| 1485 | 1485 | } |
| 1486 | 1486 | } |
@@ -1524,7 +1524,7 @@ discard block |
||
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | if (is_string($field) && !empty($this->options['via']) && false === strpos($field, '.')) { |
| 1527 | - $field = $this->options['via'] . '.' . $field; |
|
| 1527 | + $field = $this->options['via'].'.'.$field; |
|
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | if ($field instanceof Expression) { |
@@ -1708,7 +1708,7 @@ discard block |
||
| 1708 | 1708 | list($offset, $length) = explode(',', $offset); |
| 1709 | 1709 | } |
| 1710 | 1710 | |
| 1711 | - $this->options['limit'] = intval($offset) . ($length ? ',' . intval($length) : ''); |
|
| 1711 | + $this->options['limit'] = intval($offset).($length ? ','.intval($length) : ''); |
|
| 1712 | 1712 | |
| 1713 | 1713 | return $this; |
| 1714 | 1714 | } |
@@ -1765,7 +1765,7 @@ discard block |
||
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | /** @var Paginator $class */ |
| 1768 | - $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\' . ucwords($config['type']); |
|
| 1768 | + $class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\paginator\\driver\\'.ucwords($config['type']); |
|
| 1769 | 1769 | $page = isset($config['page']) ? (int) $config['page'] : call_user_func([ |
| 1770 | 1770 | $class, |
| 1771 | 1771 | 'getCurrentPage', |
@@ -1875,7 +1875,7 @@ discard block |
||
| 1875 | 1875 | |
| 1876 | 1876 | if (is_string($field)) { |
| 1877 | 1877 | if (!empty($this->options['via'])) { |
| 1878 | - $field = $this->options['via'] . '.' . $field; |
|
| 1878 | + $field = $this->options['via'].'.'.$field; |
|
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | 1881 | if (strpos($field, ',')) { |
@@ -1886,9 +1886,9 @@ discard block |
||
| 1886 | 1886 | } elseif (!empty($this->options['via'])) { |
| 1887 | 1887 | foreach ($field as $key => $val) { |
| 1888 | 1888 | if (is_numeric($key)) { |
| 1889 | - $field[$key] = $this->options['via'] . '.' . $val; |
|
| 1889 | + $field[$key] = $this->options['via'].'.'.$val; |
|
| 1890 | 1890 | } else { |
| 1891 | - $field[$this->options['via'] . '.' . $key] = $val; |
|
| 1891 | + $field[$this->options['via'].'.'.$key] = $val; |
|
| 1892 | 1892 | unset($field[$key]); |
| 1893 | 1893 | } |
| 1894 | 1894 | } |
@@ -2300,7 +2300,7 @@ discard block |
||
| 2300 | 2300 | if ($this->model) { |
| 2301 | 2301 | // 检查模型类的查询范围方法 |
| 2302 | 2302 | foreach ($scope as $name) { |
| 2303 | - $method = 'scope' . trim($name); |
|
| 2303 | + $method = 'scope'.trim($name); |
|
| 2304 | 2304 | |
| 2305 | 2305 | if (method_exists($this->model, $method)) { |
| 2306 | 2306 | call_user_func_array([$this->model, $method], $args); |
@@ -2327,7 +2327,7 @@ discard block |
||
| 2327 | 2327 | } elseif ($this->model) { |
| 2328 | 2328 | // 检测搜索器 |
| 2329 | 2329 | $fieldName = is_numeric($key) ? $field : $key; |
| 2330 | - $method = 'search' . Loader::parseName($fieldName, 1) . 'Attr'; |
|
| 2330 | + $method = 'search'.Loader::parseName($fieldName, 1).'Attr'; |
|
| 2331 | 2331 | |
| 2332 | 2332 | if (method_exists($this->model, $method)) { |
| 2333 | 2333 | $this->model->$method($this, isset($data[$field]) ? $data[$field] : null, $data, $prefix); |
@@ -2392,7 +2392,7 @@ discard block |
||
| 2392 | 2392 | $op = is_array($range) ? 'between' : '>='; |
| 2393 | 2393 | } |
| 2394 | 2394 | |
| 2395 | - return $this->parseWhereExp($logic, $field, strtolower($op) . ' time', $range, [], true); |
|
| 2395 | + return $this->parseWhereExp($logic, $field, strtolower($op).' time', $range, [], true); |
|
| 2396 | 2396 | } |
| 2397 | 2397 | |
| 2398 | 2398 | /** |
@@ -2470,7 +2470,7 @@ discard block |
||
| 2470 | 2470 | if (is_array($value)) { |
| 2471 | 2471 | $this->bind = array_merge($this->bind, $value); |
| 2472 | 2472 | } else { |
| 2473 | - $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_'; |
|
| 2473 | + $name = $name ?: 'ThinkBind_'.(count($this->bind) + 1).'_'; |
|
| 2474 | 2474 | |
| 2475 | 2475 | $this->bind[$name] = [$value, $type]; |
| 2476 | 2476 | return $name; |
@@ -2687,10 +2687,10 @@ discard block |
||
| 2687 | 2687 | $count = $this->model->$relation()->getRelationCountQuery($closure, $aggregate, $field, $aggregateField); |
| 2688 | 2688 | |
| 2689 | 2689 | if (empty($aggregateField)) { |
| 2690 | - $aggregateField = Loader::parseName($relation) . '_' . $aggregate; |
|
| 2690 | + $aggregateField = Loader::parseName($relation).'_'.$aggregate; |
|
| 2691 | 2691 | } |
| 2692 | 2692 | |
| 2693 | - $this->field(['(' . $count . ')' => $aggregateField]); |
|
| 2693 | + $this->field(['('.$count.')' => $aggregateField]); |
|
| 2694 | 2694 | } |
| 2695 | 2695 | } |
| 2696 | 2696 | |
@@ -3409,10 +3409,10 @@ discard block |
||
| 3409 | 3409 | { |
| 3410 | 3410 | if (!empty($this->model)) { |
| 3411 | 3411 | $class = get_class($this->model); |
| 3412 | - throw new ModelNotFoundException('model data Not Found:' . $class, $class, $options); |
|
| 3412 | + throw new ModelNotFoundException('model data Not Found:'.$class, $class, $options); |
|
| 3413 | 3413 | } |
| 3414 | 3414 | $table = is_array($options['table']) ? key($options['table']) : $options['table']; |
| 3415 | - throw new DataNotFoundException('table data not Found:' . $table, $table, $options); |
|
| 3415 | + throw new DataNotFoundException('table data not Found:'.$table, $table, $options); |
|
| 3416 | 3416 | } |
| 3417 | 3417 | |
| 3418 | 3418 | /** |
@@ -3548,7 +3548,7 @@ discard block |
||
| 3548 | 3548 | */ |
| 3549 | 3549 | public function buildSql($sub = true) |
| 3550 | 3550 | { |
| 3551 | - return $sub ? '( ' . $this->select(false) . ' )' : $this->select(false); |
|
| 3551 | + return $sub ? '( '.$this->select(false).' )' : $this->select(false); |
|
| 3552 | 3552 | } |
| 3553 | 3553 | |
| 3554 | 3554 | /** |
@@ -3619,7 +3619,7 @@ discard block |
||
| 3619 | 3619 | } |
| 3620 | 3620 | |
| 3621 | 3621 | if (is_string($pk)) { |
| 3622 | - $key = isset($alias) ? $alias . '.' . $pk : $pk; |
|
| 3622 | + $key = isset($alias) ? $alias.'.'.$pk : $pk; |
|
| 3623 | 3623 | // 根据主键查询 |
| 3624 | 3624 | if (is_array($data)) { |
| 3625 | 3625 | $where[$pk] = isset($data[$pk]) ? [$key, '=', $data[$pk]] : [$key, 'in', $data]; |
@@ -3630,7 +3630,7 @@ discard block |
||
| 3630 | 3630 | // 根据复合主键查询 |
| 3631 | 3631 | foreach ($pk as $key) { |
| 3632 | 3632 | if (isset($data[$key])) { |
| 3633 | - $attr = isset($alias) ? $alias . '.' . $key : $key; |
|
| 3633 | + $attr = isset($alias) ? $alias.'.'.$key : $key; |
|
| 3634 | 3634 | $where[$key] = [$attr, '=', $data[$key]]; |
| 3635 | 3635 | } else { |
| 3636 | 3636 | throw new Exception('miss complex primary data'); |
@@ -3706,7 +3706,7 @@ discard block |
||
| 3706 | 3706 | $page = $page > 0 ? $page : 1; |
| 3707 | 3707 | $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); |
| 3708 | 3708 | $offset = $listRows * ($page - 1); |
| 3709 | - $options['limit'] = $offset . ',' . $listRows; |
|
| 3709 | + $options['limit'] = $offset.','.$listRows; |
|
| 3710 | 3710 | } |
| 3711 | 3711 | |
| 3712 | 3712 | $this->options = $options; |
@@ -48,22 +48,22 @@ discard block |
||
| 48 | 48 | $array[] = $this->parseRand($query); |
| 49 | 49 | } else { |
| 50 | 50 | if (is_numeric($key)) { |
| 51 | - list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); |
|
| 51 | + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val.' '); |
|
| 52 | 52 | } else { |
| 53 | 53 | $sort = $val; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if (preg_match('/^[\w\.]+$/', $key)) { |
| 57 | 57 | $sort = strtoupper($sort); |
| 58 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
| 59 | - $array[] = $this->parseKey($query, $key, true) . $sort; |
|
| 58 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
| 59 | + $array[] = $this->parseKey($query, $key, true).$sort; |
|
| 60 | 60 | } else { |
| 61 | - throw new Exception('order express error:' . $key); |
|
| 61 | + throw new Exception('order express error:'.$key); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); |
|
| 66 | + return empty($array) ? '' : ' ORDER BY '.implode(',', $array); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -111,15 +111,15 @@ discard block |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { |
| 114 | - throw new Exception('not support data:' . $key); |
|
| 114 | + throw new Exception('not support data:'.$key); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | if ('*' != $key && !preg_match('/[,\'\"\*\(\)\[.\s]/', $key)) { |
| 118 | - $key = '[' . $key . ']'; |
|
| 118 | + $key = '['.$key.']'; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | if (isset($table)) { |
| 122 | - $key = '[' . $table . '].' . $key; |
|
| 122 | + $key = '['.$table.'].'.$key; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $key; |
@@ -141,12 +141,12 @@ discard block |
||
| 141 | 141 | $limit = explode(',', $limit); |
| 142 | 142 | |
| 143 | 143 | if (count($limit) > 1) { |
| 144 | - $limitStr = '(T1.ROW_NUMBER BETWEEN ' . $limit[0] . ' + 1 AND ' . $limit[0] . ' + ' . $limit[1] . ')'; |
|
| 144 | + $limitStr = '(T1.ROW_NUMBER BETWEEN '.$limit[0].' + 1 AND '.$limit[0].' + '.$limit[1].')'; |
|
| 145 | 145 | } else { |
| 146 | - $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND ' . $limit[0] . ")"; |
|
| 146 | + $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND '.$limit[0].")"; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - return 'WHERE ' . $limitStr; |
|
| 149 | + return 'WHERE '.$limitStr; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public function selectInsert(Query $query, $fields, $table) |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | if (!empty($limit)) { |
| 35 | 35 | $limit = explode(',', $limit); |
| 36 | 36 | if (count($limit) > 1) { |
| 37 | - $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; |
|
| 37 | + $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' '; |
|
| 38 | 38 | } else { |
| 39 | - $limitStr .= ' LIMIT ' . $limit[0] . ' '; |
|
| 39 | + $limitStr .= ' LIMIT '.$limit[0].' '; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if (isset($table)) { |
| 91 | - $key = $table . '.' . $key; |
|
| 91 | + $key = $table.'.'.$key; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | return $key; |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | $bind = $this->connection->getFieldsBind($options['table']); |
| 63 | 63 | |
| 64 | 64 | foreach ($dataSet as $k => $data) { |
| 65 | - $data = $this->parseData($query, $data, $allowFields, $bind, '_' . $k); |
|
| 65 | + $data = $this->parseData($query, $data, $allowFields, $bind, '_'.$k); |
|
| 66 | 66 | |
| 67 | - $values[] = '( ' . implode(',', array_values($data)) . ' )'; |
|
| 67 | + $values[] = '( '.implode(',', array_values($data)).' )'; |
|
| 68 | 68 | |
| 69 | 69 | if (!isset($insertFields)) { |
| 70 | 70 | $insertFields = array_keys($data); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $value = $value->getValue(); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - return $key . ' ' . $exp . ' ' . $value; |
|
| 107 | + return $key.' '.$exp.' '.$value; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | // JSON字段支持 |
| 130 | 130 | list($field, $name) = explode('->', $key, 2); |
| 131 | 131 | |
| 132 | - return 'json_extract(' . $this->parseKey($query, $field, true) . ', \'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->', '.', $name) . '\')'; |
|
| 132 | + return 'json_extract('.$this->parseKey($query, $field, true).', \'$'.(strpos($name, '[') === 0 ? '' : '.').str_replace('->', '.', $name).'\')'; |
|
| 133 | 133 | } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { |
| 134 | 134 | list($table, $key) = explode('.', $key, 2); |
| 135 | 135 | |
@@ -146,11 +146,11 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | if ($strict && !preg_match('/^[\w\.\*]+$/', $key)) { |
| 149 | - throw new Exception('not support data:' . $key); |
|
| 149 | + throw new Exception('not support data:'.$key); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | if ('*' != $key && !preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { |
| 153 | - $key = '`' . $key . '`'; |
|
| 153 | + $key = '`'.$key.'`'; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | if (isset($table)) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $table = str_replace('.', '`.`', $table); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $key = '`' . $table . '`.' . $key; |
|
| 161 | + $key = '`'.$table.'`.'.$key; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | return $key; |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | if (!empty($limit)) { |
| 38 | 38 | $limit = explode(',', $limit); |
| 39 | 39 | if (count($limit) > 1) { |
| 40 | - $limitStr .= ' LIMIT ' . $limit[1] . ' OFFSET ' . $limit[0] . ' '; |
|
| 40 | + $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' '; |
|
| 41 | 41 | } else { |
| 42 | - $limitStr .= ' LIMIT ' . $limit[0] . ' '; |
|
| 42 | + $limitStr .= ' LIMIT '.$limit[0].' '; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | if (strpos($key, '->') && false === strpos($key, '(')) { |
| 68 | 68 | // JSON字段支持 |
| 69 | 69 | list($field, $name) = explode('->', $key); |
| 70 | - $key = $field . '->>\'' . $name . '\''; |
|
| 70 | + $key = $field.'->>\''.$name.'\''; |
|
| 71 | 71 | } elseif (strpos($key, '.')) { |
| 72 | 72 | list($table, $key) = explode('.', $key, 2); |
| 73 | 73 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if (isset($table)) { |
| 87 | - $key = $table . '.' . $key; |
|
| 87 | + $key = $table.'.'.$key; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | return $key; |
@@ -132,23 +132,23 @@ discard block |
||
| 132 | 132 | if (false !== strpos($key, '->')) { |
| 133 | 133 | list($key, $name) = explode('->', $key); |
| 134 | 134 | $item = $this->parseKey($query, $key); |
| 135 | - $result[$item] = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key, $val, $bind) . ')'; |
|
| 135 | + $result[$item] = 'json_set('.$item.', \'$.'.$name.'\', '.$this->parseDataBind($query, $key, $val, $bind).')'; |
|
| 136 | 136 | } elseif ('*' == $options['field'] && false === strpos($key, '.') && !in_array($key, $fields, true)) { |
| 137 | 137 | if ($options['strict']) { |
| 138 | - throw new Exception('fields not exists:[' . $key . ']'); |
|
| 138 | + throw new Exception('fields not exists:['.$key.']'); |
|
| 139 | 139 | } |
| 140 | 140 | } elseif (is_null($val)) { |
| 141 | 141 | $result[$item] = 'NULL'; |
| 142 | 142 | } elseif (is_array($val) && !empty($val)) { |
| 143 | 143 | switch (strtoupper($val[0])) { |
| 144 | 144 | case 'INC': |
| 145 | - $result[$item] = $item . ' + ' . floatval($val[1]); |
|
| 145 | + $result[$item] = $item.' + '.floatval($val[1]); |
|
| 146 | 146 | break; |
| 147 | 147 | case 'DEC': |
| 148 | - $result[$item] = $item . ' - ' . floatval($val[1]); |
|
| 148 | + $result[$item] = $item.' - '.floatval($val[1]); |
|
| 149 | 149 | break; |
| 150 | 150 | case 'EXP': |
| 151 | - throw new Exception('not support data:[' . $val[0] . ']'); |
|
| 151 | + throw new Exception('not support data:['.$val[0].']'); |
|
| 152 | 152 | } |
| 153 | 153 | } elseif (is_scalar($val)) { |
| 154 | 154 | // 过滤非标量数据 |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $name = $query->bind($data, isset($bind[$key]) ? $bind[$key] : PDO::PARAM_STR); |
| 178 | 178 | |
| 179 | - return ':' . $name; |
|
| 179 | + return ':'.$name; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | foreach ($fields as $key => $field) { |
| 211 | 211 | if (!is_numeric($key)) { |
| 212 | - $array[] = $this->parseKey($query, $key) . ' AS ' . $this->parseKey($query, $field, true); |
|
| 212 | + $array[] = $this->parseKey($query, $key).' AS '.$this->parseKey($query, $field, true); |
|
| 213 | 213 | } else { |
| 214 | 214 | $array[] = $this->parseKey($query, $field); |
| 215 | 215 | } |
@@ -236,12 +236,12 @@ discard block |
||
| 236 | 236 | foreach ((array) $tables as $key => $table) { |
| 237 | 237 | if (!is_numeric($key)) { |
| 238 | 238 | $key = $this->connection->parseSqlTable($key); |
| 239 | - $item[] = $this->parseKey($query, $key) . ' ' . $this->parseKey($query, $table); |
|
| 239 | + $item[] = $this->parseKey($query, $key).' '.$this->parseKey($query, $table); |
|
| 240 | 240 | } else { |
| 241 | 241 | $table = $this->connection->parseSqlTable($table); |
| 242 | 242 | |
| 243 | 243 | if (isset($options['alias'][$table])) { |
| 244 | - $item[] = $this->parseKey($query, $table) . ' ' . $this->parseKey($query, $options['alias'][$table]); |
|
| 244 | + $item[] = $this->parseKey($query, $table).' '.$this->parseKey($query, $options['alias'][$table]); |
|
| 245 | 245 | } else { |
| 246 | 246 | $item[] = $this->parseKey($query, $table); |
| 247 | 247 | } |
@@ -268,11 +268,11 @@ discard block |
||
| 268 | 268 | list($field, $condition) = $options['soft_delete']; |
| 269 | 269 | |
| 270 | 270 | $binds = $this->connection->getFieldsBind($options['table']); |
| 271 | - $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; |
|
| 272 | - $whereStr = $whereStr . $this->parseWhereItem($query, $field, $condition, '', $binds); |
|
| 271 | + $whereStr = $whereStr ? '( '.$whereStr.' ) AND ' : ''; |
|
| 272 | + $whereStr = $whereStr.$this->parseWhereItem($query, $field, $condition, '', $binds); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | - return empty($whereStr) ? '' : ' WHERE ' . $whereStr; |
|
| 275 | + return empty($whereStr) ? '' : ' WHERE '.$whereStr; |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -296,17 +296,17 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | foreach ($val as $value) { |
| 298 | 298 | if ($value instanceof Expression) { |
| 299 | - $str[] = ' ' . $logic . ' ( ' . $value->getValue() . ' )'; |
|
| 299 | + $str[] = ' '.$logic.' ( '.$value->getValue().' )'; |
|
| 300 | 300 | continue; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | if (is_array($value)) { |
| 304 | 304 | if (key($value) !== 0) { |
| 305 | - throw new Exception('where express error:' . var_export($value, true)); |
|
| 305 | + throw new Exception('where express error:'.var_export($value, true)); |
|
| 306 | 306 | } |
| 307 | 307 | $field = array_shift($value); |
| 308 | 308 | } elseif (!($value instanceof \Closure)) { |
| 309 | - throw new Exception('where express error:' . var_export($value, true)); |
|
| 309 | + throw new Exception('where express error:'.var_export($value, true)); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | if ($value instanceof \Closure) { |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $whereClause = $this->buildWhere($query, $newQuery->getOptions('where')); |
| 317 | 317 | |
| 318 | 318 | if (!empty($whereClause)) { |
| 319 | - $str[] = ' ' . $logic . ' ( ' . $whereClause . ' )'; |
|
| 319 | + $str[] = ' '.$logic.' ( '.$whereClause.' )'; |
|
| 320 | 320 | } |
| 321 | 321 | } elseif (is_array($field)) { |
| 322 | 322 | array_unshift($value, $field); |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | $str2[] = $this->parseWhereItem($query, array_shift($item), $item, $logic, $binds); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - $str[] = ' ' . $logic . ' ( ' . implode(' AND ', $str2) . ' )'; |
|
| 328 | + $str[] = ' '.$logic.' ( '.implode(' AND ', $str2).' )'; |
|
| 329 | 329 | } elseif (strpos($field, '|')) { |
| 330 | 330 | // 不同字段使用相同查询条件(OR) |
| 331 | 331 | $array = explode('|', $field); |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | $item[] = $this->parseWhereItem($query, $k, $value, '', $binds); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - $str[] = ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )'; |
|
| 338 | + $str[] = ' '.$logic.' ( '.implode(' OR ', $item).' )'; |
|
| 339 | 339 | } elseif (strpos($field, '&')) { |
| 340 | 340 | // 不同字段使用相同查询条件(AND) |
| 341 | 341 | $array = explode('&', $field); |
@@ -345,11 +345,11 @@ discard block |
||
| 345 | 345 | $item[] = $this->parseWhereItem($query, $k, $value, '', $binds); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - $str[] = ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )'; |
|
| 348 | + $str[] = ' '.$logic.' ( '.implode(' AND ', $item).' )'; |
|
| 349 | 349 | } else { |
| 350 | 350 | // 对字段使用表达式查询 |
| 351 | 351 | $field = is_string($field) ? $field : ''; |
| 352 | - $str[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $logic, $binds); |
|
| 352 | + $str[] = ' '.$logic.' '.$this->parseWhereItem($query, $field, $value, $logic, $binds); |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $str[] = $this->parseWhereItem($query, $field, $item, $rule, $binds); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - return '( ' . implode(' ' . $rule . ' ', $str) . ' )'; |
|
| 390 | + return '( '.implode(' '.$rule.' ', $str).' )'; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | // 检测操作符 |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | if (0 === strpos($value, ':') && $query->isBind(substr($value, 1))) { |
| 415 | 415 | } else { |
| 416 | 416 | $name = $query->bind($value, $bindType); |
| 417 | - $value = ':' . $name; |
|
| 417 | + $value = ':'.$name; |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | if (!isset($whereStr)) { |
| 430 | - throw new Exception('where express error:' . $exp); |
|
| 430 | + throw new Exception('where express error:'.$exp); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | return $whereStr; |
@@ -451,12 +451,12 @@ discard block |
||
| 451 | 451 | if (is_array($value)) { |
| 452 | 452 | foreach ($value as $item) { |
| 453 | 453 | $name = $query->bind($item, PDO::PARAM_STR); |
| 454 | - $array[] = $key . ' ' . $exp . ' :' . $name; |
|
| 454 | + $array[] = $key.' '.$exp.' :'.$name; |
|
| 455 | 455 | } |
| 456 | 456 | |
| 457 | - $whereStr = '(' . implode(' ' . strtoupper($logic) . ' ', $array) . ')'; |
|
| 457 | + $whereStr = '('.implode(' '.strtoupper($logic).' ', $array).')'; |
|
| 458 | 458 | } else { |
| 459 | - $whereStr = $key . ' ' . $exp . ' ' . $value; |
|
| 459 | + $whereStr = $key.' '.$exp.' '.$value; |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | return $whereStr; |
@@ -479,10 +479,10 @@ discard block |
||
| 479 | 479 | list($op, $field2) = $value; |
| 480 | 480 | |
| 481 | 481 | if (!in_array($op, ['=', '<>', '>', '>=', '<', '<='])) { |
| 482 | - throw new Exception('where express error:' . var_export($value, true)); |
|
| 482 | + throw new Exception('where express error:'.var_export($value, true)); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field2, true) . ' )'; |
|
| 485 | + return '( '.$key.' '.$op.' '.$this->parseKey($query, $field2, true).' )'; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | /** |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | protected function parseExp(Query $query, $key, $exp, Expression $value, $field, $bindType) |
| 500 | 500 | { |
| 501 | 501 | // 表达式查询 |
| 502 | - return '( ' . $key . ' ' . $value->getValue() . ' )'; |
|
| 502 | + return '( '.$key.' '.$value->getValue().' )'; |
|
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | protected function parseNull(Query $query, $key, $exp, $value, $field, $bindType) |
| 517 | 517 | { |
| 518 | 518 | // NULL 查询 |
| 519 | - return $key . ' IS ' . $exp; |
|
| 519 | + return $key.' IS '.$exp; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | $min = $query->bind($data[0], $bindType); |
| 539 | 539 | $max = $query->bind($data[1], $bindType); |
| 540 | 540 | |
| 541 | - return $key . ' ' . $exp . ' :' . $min . ' AND :' . $max . ' '; |
|
| 541 | + return $key.' '.$exp.' :'.$min.' AND :'.$max.' '; |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -560,10 +560,10 @@ discard block |
||
| 560 | 560 | } elseif ($value instanceof Expression) { |
| 561 | 561 | $value = $value->getValue(); |
| 562 | 562 | } else { |
| 563 | - throw new Exception('where express error:' . $value); |
|
| 563 | + throw new Exception('where express error:'.$value); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | - return $exp . ' (' . $value . ')'; |
|
| 566 | + return $exp.' ('.$value.')'; |
|
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | /** |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | protected function parseTime(Query $query, $key, $exp, $value, $field, $bindType) |
| 581 | 581 | { |
| 582 | - return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType); |
|
| 582 | + return $key.' '.substr($exp, 0, 2).' '.$this->parseDateTime($query, $value, $field, $bindType); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | protected function parseCompare(Query $query, $key, $exp, $value, $field, $bindType) |
| 597 | 597 | { |
| 598 | 598 | if (is_array($value)) { |
| 599 | - throw new Exception('where express error:' . $exp . var_export($value, true)); |
|
| 599 | + throw new Exception('where express error:'.$exp.var_export($value, true)); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | // 比较运算 |
@@ -605,10 +605,10 @@ discard block |
||
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | if ('=' == $exp && is_null($value)) { |
| 608 | - return $key . ' IS NULL'; |
|
| 608 | + return $key.' IS NULL'; |
|
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - return $key . ' ' . $exp . ' ' . $value; |
|
| 611 | + return $key.' '.$exp.' '.$value; |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /** |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $value = explode(',', $value); |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - return $key . ' ' . substr($exp, 0, -4) |
|
| 631 | + return $key.' '.substr($exp, 0, -4) |
|
| 632 | 632 | . $this->parseDateTime($query, $value[0], $field, $bindType) |
| 633 | 633 | . ' AND ' |
| 634 | 634 | . $this->parseDateTime($query, $value[1], $field, $bindType); |
@@ -659,18 +659,18 @@ discard block |
||
| 659 | 659 | |
| 660 | 660 | foreach ($value as $k => $v) { |
| 661 | 661 | $name = $query->bind($v, $bindType); |
| 662 | - $array[] = ':' . $name; |
|
| 662 | + $array[] = ':'.$name; |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | if (count($array) == 1) { |
| 666 | - return $key . ('IN' == $exp ? ' = ' : ' <> ') . $array[0]; |
|
| 666 | + return $key.('IN' == $exp ? ' = ' : ' <> ').$array[0]; |
|
| 667 | 667 | } else { |
| 668 | 668 | $zone = implode(',', $array); |
| 669 | 669 | $value = empty($zone) ? "''" : $zone; |
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | - return $key . ' ' . $exp . ' (' . $value . ')'; |
|
| 673 | + return $key.' '.$exp.' ('.$value.')'; |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | $name = $query->bind($value, $bindType); |
| 737 | 737 | |
| 738 | - return ':' . $name; |
|
| 738 | + return ':'.$name; |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | /** |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | */ |
| 748 | 748 | protected function parseLimit(Query $query, $limit) |
| 749 | 749 | { |
| 750 | - return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; |
|
| 750 | + return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT '.$limit.' ' : ''; |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | /** |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | } elseif (strpos($val, '=')) { |
| 774 | 774 | list($val1, $val2) = explode('=', $val, 2); |
| 775 | 775 | |
| 776 | - $condition[] = $this->parseKey($query, $val1) . '=' . $this->parseKey($query, $val2); |
|
| 776 | + $condition[] = $this->parseKey($query, $val1).'='.$this->parseKey($query, $val2); |
|
| 777 | 777 | } else { |
| 778 | 778 | $condition[] = $val; |
| 779 | 779 | } |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | |
| 782 | 782 | $table = $this->parseTable($query, $table); |
| 783 | 783 | |
| 784 | - $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . implode(' AND ', $condition); |
|
| 784 | + $joinStr .= ' '.$type.' JOIN '.$table.' ON '.implode(' AND ', $condition); |
|
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | 787 | |
@@ -806,22 +806,22 @@ discard block |
||
| 806 | 806 | $array[] = $this->parseRand($query); |
| 807 | 807 | } elseif (is_string($val)) { |
| 808 | 808 | if (is_numeric($key)) { |
| 809 | - list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val . ' '); |
|
| 809 | + list($key, $sort) = explode(' ', strpos($val, ' ') ? $val : $val.' '); |
|
| 810 | 810 | } else { |
| 811 | 811 | $sort = $val; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | 814 | if (preg_match('/^[\w\.]+$/', $key)) { |
| 815 | 815 | $sort = strtoupper($sort); |
| 816 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
| 817 | - $array[] = $this->parseKey($query, $key, true) . $sort; |
|
| 816 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
| 817 | + $array[] = $this->parseKey($query, $key, true).$sort; |
|
| 818 | 818 | } else { |
| 819 | - throw new Exception('order express error:' . $key); |
|
| 819 | + throw new Exception('order express error:'.$key); |
|
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | - return empty($array) ? '' : ' ORDER BY ' . implode(',', $array); |
|
| 824 | + return empty($array) ? '' : ' ORDER BY '.implode(',', $array); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | $sort = strtoupper($sort); |
| 845 | - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; |
|
| 845 | + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' '.$sort : ''; |
|
| 846 | 846 | |
| 847 | 847 | $options = $query->getOptions(); |
| 848 | 848 | $bind = $this->connection->getFieldsBind($options['table']); |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $val[$k] = $this->parseDataBind($query, $key, $item, $bind); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - return 'field(' . $this->parseKey($query, $key, true) . ',' . implode(',', $val) . ')' . $sort; |
|
| 854 | + return 'field('.$this->parseKey($query, $key, true).','.implode(',', $val).')'.$sort; |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | $val[] = $this->parseKey($query, $key); |
| 876 | 876 | } |
| 877 | 877 | |
| 878 | - return ' GROUP BY ' . implode(',', $val); |
|
| 878 | + return ' GROUP BY '.implode(',', $val); |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | /** |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | */ |
| 888 | 888 | protected function parseHaving(Query $query, $having) |
| 889 | 889 | { |
| 890 | - return !empty($having) ? ' HAVING ' . $having : ''; |
|
| 890 | + return !empty($having) ? ' HAVING '.$having : ''; |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | /** |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | $comment = strstr($comment, '*/', true); |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | - return !empty($comment) ? ' /* ' . $comment . ' */' : ''; |
|
| 906 | + return !empty($comment) ? ' /* '.$comment.' */' : ''; |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
@@ -936,13 +936,13 @@ discard block |
||
| 936 | 936 | |
| 937 | 937 | foreach ($union as $u) { |
| 938 | 938 | if ($u instanceof \Closure) { |
| 939 | - $sql[] = $type . ' ' . $this->parseClosure($query, $u); |
|
| 939 | + $sql[] = $type.' '.$this->parseClosure($query, $u); |
|
| 940 | 940 | } elseif (is_string($u)) { |
| 941 | - $sql[] = $type . ' ( ' . $this->connection->parseSqlTable($u) . ' )'; |
|
| 941 | + $sql[] = $type.' ( '.$this->connection->parseSqlTable($u).' )'; |
|
| 942 | 942 | } |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - return ' ' . implode(' ', $sql); |
|
| 945 | + return ' '.implode(' ', $sql); |
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | /** |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | if (is_bool($lock)) { |
| 974 | 974 | return $lock ? ' FOR UPDATE ' : ''; |
| 975 | 975 | } elseif (is_string($lock) && !empty($lock)) { |
| 976 | - return ' ' . trim($lock) . ' '; |
|
| 976 | + return ' '.trim($lock).' '; |
|
| 977 | 977 | } |
| 978 | 978 | } |
| 979 | 979 | |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | foreach ($dataSet as $data) { |
| 1065 | 1065 | $data = $this->parseData($query, $data, $allowFields, $bind); |
| 1066 | 1066 | |
| 1067 | - $values[] = 'SELECT ' . implode(',', array_values($data)); |
|
| 1067 | + $values[] = 'SELECT '.implode(',', array_values($data)); |
|
| 1068 | 1068 | |
| 1069 | 1069 | if (!isset($insertFields)) { |
| 1070 | 1070 | $insertFields = array_keys($data); |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | $field = $this->parseKey($query, $field, true); |
| 1108 | 1108 | } |
| 1109 | 1109 | |
| 1110 | - return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query); |
|
| 1110 | + return 'INSERT INTO '.$this->parseTable($query, $table).' ('.implode(',', $fields).') '.$this->select($query); |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | /** |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | foreach ($data as $key => $val) { |
| 1130 | - $set[] = $key . ' = ' . $val; |
|
| 1130 | + $set[] = $key.' = '.$val; |
|
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | 1133 | return str_replace( |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | ['%TABLE%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], |
| 1160 | 1160 | [ |
| 1161 | 1161 | $this->parseTable($query, $options['table']), |
| 1162 | - !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', |
|
| 1162 | + !empty($options['using']) ? ' USING '.$this->parseTable($query, $options['using']).' ' : '', |
|
| 1163 | 1163 | $this->parseJoin($query, $options['join']), |
| 1164 | 1164 | $this->parseWhere($query, $options['where']), |
| 1165 | 1165 | $this->parseOrder($query, $options['order']), |