@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | public function setRelation($name, $value, $data = []) |
| 105 | 105 | { |
| 106 | 106 | // 检测修改器 |
| 107 | - $method = 'set' . Loader::parseName($name, 1) . 'Attr'; |
|
| 107 | + $method = 'set'.Loader::parseName($name, 1).'Attr'; |
|
| 108 | 108 | |
| 109 | 109 | if (method_exists($this, $method)) { |
| 110 | 110 | $value = $this->$method($value, array_merge($this->data, $data)); |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | $count = $this->$relation()->relationCount($result, $closure, $aggregate, $field, $name); |
| 325 | 325 | |
| 326 | 326 | if (empty($name)) { |
| 327 | - $name = Loader::parseName($relation) . '_' . $aggregate; |
|
| 327 | + $name = Loader::parseName($relation).'_'.$aggregate; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | $result->setAttr($name, $count); |
@@ -423,8 +423,8 @@ discard block |
||
| 423 | 423 | // 记录当前关联信息 |
| 424 | 424 | $model = $this->parseModel($model); |
| 425 | 425 | $name = Loader::parseName(basename(str_replace('\\', '/', $model))); |
| 426 | - $table = $table ?: Loader::parseName($this->name) . '_' . $name; |
|
| 427 | - $foreignKey = $foreignKey ?: $name . '_id'; |
|
| 426 | + $table = $table ?: Loader::parseName($this->name).'_'.$name; |
|
| 427 | + $foreignKey = $foreignKey ?: $name.'_id'; |
|
| 428 | 428 | $localKey = $localKey ?: $this->getForeignKey($this->name); |
| 429 | 429 | |
| 430 | 430 | return new BelongsToMany($this, $model, $table, $foreignKey, $localKey); |
@@ -451,8 +451,8 @@ discard block |
||
| 451 | 451 | if (is_array($morph)) { |
| 452 | 452 | list($morphType, $foreignKey) = $morph; |
| 453 | 453 | } else { |
| 454 | - $morphType = $morph . '_type'; |
|
| 455 | - $foreignKey = $morph . '_id'; |
|
| 454 | + $morphType = $morph.'_type'; |
|
| 455 | + $foreignKey = $morph.'_id'; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | $type = $type ?: get_class($this); |
@@ -483,8 +483,8 @@ discard block |
||
| 483 | 483 | if (is_array($morph)) { |
| 484 | 484 | list($morphType, $foreignKey) = $morph; |
| 485 | 485 | } else { |
| 486 | - $morphType = $morph . '_type'; |
|
| 487 | - $foreignKey = $morph . '_id'; |
|
| 486 | + $morphType = $morph.'_type'; |
|
| 487 | + $foreignKey = $morph.'_id'; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | return new MorphMany($this, $model, $foreignKey, $morphType, $type); |
@@ -510,8 +510,8 @@ discard block |
||
| 510 | 510 | if (is_array($morph)) { |
| 511 | 511 | list($morphType, $foreignKey) = $morph; |
| 512 | 512 | } else { |
| 513 | - $morphType = $morph . '_type'; |
|
| 514 | - $foreignKey = $morph . '_id'; |
|
| 513 | + $morphType = $morph.'_type'; |
|
| 514 | + $foreignKey = $morph.'_id'; |
|
| 515 | 515 | } |
| 516 | 516 | |
| 517 | 517 | return new MorphTo($this, $morphType, $foreignKey, $alias, $relation); |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | $name = basename(str_replace('\\', '/', $name)); |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - return Loader::parseName($name) . '_id'; |
|
| 550 | + return Loader::parseName($name).'_id'; |
|
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $query->where($data); |
| 147 | 147 | $data = null; |
| 148 | 148 | } elseif ($data instanceof \Closure) { |
| 149 | - call_user_func_array($data, [ & $query]); |
|
| 149 | + call_user_func_array($data, [& $query]); |
|
| 150 | 150 | $data = null; |
| 151 | 151 | } elseif (is_null($data)) { |
| 152 | 152 | return false; |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | if (false === strpos($field, '.')) { |
| 216 | - $field = '__TABLE__.' . $field; |
|
| 216 | + $field = '__TABLE__.'.$field; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | if (!$read && strpos($field, '.')) { |
@@ -231,7 +231,7 @@ |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | return $this->query |
| 234 | - ->whereExp($this->morphKey, '=' . $this->parent->getTable() . '.' . $this->parent->getPk()) |
|
| 234 | + ->whereExp($this->morphKey, '='.$this->parent->getTable().'.'.$this->parent->getPk()) |
|
| 235 | 235 | ->where($this->morphType, '=', $this->type) |
| 236 | 236 | ->fetchSql() |
| 237 | 237 | ->$aggregate($field); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // 关联查询 |
| 153 | 153 | $pk = $this->parent->getPk(); |
| 154 | 154 | |
| 155 | - $condition[] = ['pivot.' . $localKey, '=', $this->parent->$pk]; |
|
| 155 | + $condition[] = ['pivot.'.$localKey, '=', $this->parent->$pk]; |
|
| 156 | 156 | |
| 157 | 157 | return $this->belongsToManyQuery($foreignKey, $localKey, $condition); |
| 158 | 158 | } |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | */ |
| 282 | 282 | public function wherePivot($field, $op = null, $condition = null) |
| 283 | 283 | { |
| 284 | - $this->query->where('pivot.' . $field, $op, $condition); |
|
| 284 | + $this->query->where('pivot.'.$field, $op, $condition); |
|
| 285 | 285 | return $this; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | if (!empty($range)) { |
| 312 | 312 | // 查询关联数据 |
| 313 | 313 | $data = $this->eagerlyManyToMany([ |
| 314 | - ['pivot.' . $localKey, 'in', $range], |
|
| 314 | + ['pivot.'.$localKey, 'in', $range], |
|
| 315 | 315 | ], $relation, $subRelation, $closure); |
| 316 | 316 | |
| 317 | 317 | // 关联属性名 |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | $pk = $result->$pk; |
| 346 | 346 | // 查询管理数据 |
| 347 | 347 | $data = $this->eagerlyManyToMany([ |
| 348 | - ['pivot.' . $this->localKey, '=', $pk], |
|
| 348 | + ['pivot.'.$this->localKey, '=', $pk], |
|
| 349 | 349 | ], $relation, $subRelation, $closure); |
| 350 | 350 | |
| 351 | 351 | // 关联数据封装 |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ |
| 389 | - ['pivot.' . $this->localKey, '=', $pk], |
|
| 389 | + ['pivot.'.$this->localKey, '=', $pk], |
|
| 390 | 390 | ])->$aggregate($field); |
| 391 | 391 | } |
| 392 | 392 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | |
| 412 | 412 | return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ |
| 413 | 413 | [ |
| 414 | - 'pivot.' . $this->localKey, 'exp', $this->query->raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()), |
|
| 414 | + 'pivot.'.$this->localKey, 'exp', $this->query->raw('='.$this->parent->getTable().'.'.$this->parent->getPk()), |
|
| 415 | 415 | ], |
| 416 | 416 | ])->fetchSql()->$aggregate($field); |
| 417 | 417 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | |
| 480 | 480 | if (empty($this->baseQuery)) { |
| 481 | 481 | $relationFk = $this->query->getPk(); |
| 482 | - $query->join([$table => 'pivot'], 'pivot.' . $foreignKey . '=' . $tableName . '.' . $relationFk) |
|
| 482 | + $query->join([$table => 'pivot'], 'pivot.'.$foreignKey.'='.$tableName.'.'.$relationFk) |
|
| 483 | 483 | ->where($condition); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -701,8 +701,8 @@ discard block |
||
| 701 | 701 | $table = $this->pivot->getTable(); |
| 702 | 702 | |
| 703 | 703 | $this->query |
| 704 | - ->join([$table => 'pivot'], 'pivot.' . $this->foreignKey . '=' . $this->query->getTable() . '.' . $this->query->getPk()) |
|
| 705 | - ->where('pivot.' . $this->localKey, $this->parent->$pk); |
|
| 704 | + ->join([$table => 'pivot'], 'pivot.'.$this->foreignKey.'='.$this->query->getTable().'.'.$this->query->getPk()) |
|
| 705 | + ->where('pivot.'.$this->localKey, $this->parent->$pk); |
|
| 706 | 706 | $this->baseQuery = true; |
| 707 | 707 | } |
| 708 | 708 | } |
@@ -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 | } |
@@ -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; |