@@ -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; |
@@ -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; |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | // 记录初始化信息 |
| 192 | - Container::get('app')->log('[ DB ] INIT ' . $config['type']); |
|
| 192 | + Container::get('app')->log('[ DB ] INIT '.$config['type']); |
|
| 193 | 193 | |
| 194 | 194 | if (true === $name) { |
| 195 | 195 | $name = md5(serialize($config)); |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | return $this->builderClassName; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - return $this->getConfig('builder') ?: '\\think\\db\\builder\\' . ucfirst($this->getConfig('type')); |
|
| 215 | + return $this->getConfig('builder') ?: '\\think\\db\\builder\\'.ucfirst($this->getConfig('type')); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -326,8 +326,8 @@ discard block |
||
| 326 | 326 | public function parseSqlTable($sql) |
| 327 | 327 | { |
| 328 | 328 | if (false !== strpos($sql, '__')) { |
| 329 | - $sql = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function ($match) { |
|
| 330 | - return $this->getConfig('prefix') . strtolower($match[1]); |
|
| 329 | + $sql = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) { |
|
| 330 | + return $this->getConfig('prefix').strtolower($match[1]); |
|
| 331 | 331 | }, $sql); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -362,14 +362,14 @@ discard block |
||
| 362 | 362 | list($tableName) = explode(' ', $tableName); |
| 363 | 363 | |
| 364 | 364 | if (false === strpos($tableName, '.')) { |
| 365 | - $schema = $this->getConfig('database') . '.' . $tableName; |
|
| 365 | + $schema = $this->getConfig('database').'.'.$tableName; |
|
| 366 | 366 | } else { |
| 367 | 367 | $schema = $tableName; |
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | if (!isset(self::$info[$schema])) { |
| 371 | 371 | // 读取缓存 |
| 372 | - $cacheFile = Container::get('app')->getRuntimePath() . 'schema' . DIRECTORY_SEPARATOR . $schema . '.php'; |
|
| 372 | + $cacheFile = Container::get('app')->getRuntimePath().'schema'.DIRECTORY_SEPARATOR.$schema.'.php'; |
|
| 373 | 373 | |
| 374 | 374 | if (!$this->config['debug'] && is_file($cacheFile)) { |
| 375 | 375 | $info = include $cacheFile; |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | $fields = array_keys($info); |
| 381 | - $bind = $type = []; |
|
| 381 | + $bind = $type = []; |
|
| 382 | 382 | |
| 383 | 383 | foreach ($info as $key => $val) { |
| 384 | 384 | // 记录字段类型 |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | |
| 530 | 530 | if ($config['debug']) { |
| 531 | 531 | // 记录数据库连接信息 |
| 532 | - $this->log('[ DB ] CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']); |
|
| 532 | + $this->log('[ DB ] CONNECT:[ UseTime:'.number_format(microtime(true) - $startTime, 6).'s ] '.$config['dsn']); |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | return $this->links[$linkNum]; |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | list($distinct, $field) = explode(' ', $field); |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | - $field = $aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $this->builder->parseKey($query, $field, true) . ') AS tp_' . strtolower($aggregate); |
|
| 1325 | + $field = $aggregate.'('.(!empty($distinct) ? 'DISTINCT ' : '').$this->builder->parseKey($query, $field, true).') AS tp_'.strtolower($aggregate); |
|
| 1326 | 1326 | |
| 1327 | 1327 | return $this->value($query, $field, 0, false); |
| 1328 | 1328 | } |
@@ -1468,15 +1468,14 @@ discard block |
||
| 1468 | 1468 | $type = is_array($val) ? $val[1] : PDO::PARAM_STR; |
| 1469 | 1469 | |
| 1470 | 1470 | if ((self::PARAM_FLOAT == $type || PDO::PARAM_STR == $type) && is_string($value)) { |
| 1471 | - $value = '\'' . addslashes($value) . '\''; |
|
| 1471 | + $value = '\''.addslashes($value).'\''; |
|
| 1472 | 1472 | } elseif (PDO::PARAM_INT == $type && '' === $value) { |
| 1473 | 1473 | $value = 0; |
| 1474 | 1474 | } |
| 1475 | 1475 | |
| 1476 | 1476 | // 判断占位符 |
| 1477 | 1477 | $sql = is_numeric($key) ? |
| 1478 | - substr_replace($sql, $value, strpos($sql, '?'), 1) : |
|
| 1479 | - substr_replace($sql, $value, strpos($sql, ':' . $key), strlen(':' . $key)); |
|
| 1478 | + substr_replace($sql, $value, strpos($sql, '?'), 1) : substr_replace($sql, $value, strpos($sql, ':'.$key), strlen(':'.$key)); |
|
| 1480 | 1479 | } |
| 1481 | 1480 | |
| 1482 | 1481 | return rtrim($sql); |
@@ -1495,7 +1494,7 @@ discard block |
||
| 1495 | 1494 | { |
| 1496 | 1495 | foreach ($bind as $key => $val) { |
| 1497 | 1496 | // 占位符 |
| 1498 | - $param = is_int($key) ? $key + 1 : ':' . $key; |
|
| 1497 | + $param = is_int($key) ? $key + 1 : ':'.$key; |
|
| 1499 | 1498 | |
| 1500 | 1499 | if (is_array($val)) { |
| 1501 | 1500 | if (PDO::PARAM_INT == $val[1] && '' === $val[0]) { |
@@ -1531,7 +1530,7 @@ discard block |
||
| 1531 | 1530 | protected function bindParam($bind) |
| 1532 | 1531 | { |
| 1533 | 1532 | foreach ($bind as $key => $val) { |
| 1534 | - $param = is_int($key) ? $key + 1 : ':' . $key; |
|
| 1533 | + $param = is_int($key) ? $key + 1 : ':'.$key; |
|
| 1535 | 1534 | |
| 1536 | 1535 | if (is_array($val)) { |
| 1537 | 1536 | array_unshift($val, $param); |
@@ -1687,7 +1686,7 @@ discard block |
||
| 1687 | 1686 | $this->linkID->beginTransaction(); |
| 1688 | 1687 | } elseif ($this->transTimes > 1 && $this->supportSavepoint()) { |
| 1689 | 1688 | $this->linkID->exec( |
| 1690 | - $this->parseSavepoint('trans' . $this->transTimes) |
|
| 1689 | + $this->parseSavepoint('trans'.$this->transTimes) |
|
| 1691 | 1690 | ); |
| 1692 | 1691 | } |
| 1693 | 1692 | } catch (\Exception $e) { |
@@ -1730,7 +1729,7 @@ discard block |
||
| 1730 | 1729 | $this->linkID->rollBack(); |
| 1731 | 1730 | } elseif ($this->transTimes > 1 && $this->supportSavepoint()) { |
| 1732 | 1731 | $this->linkID->exec( |
| 1733 | - $this->parseSavepointRollBack('trans' . $this->transTimes) |
|
| 1732 | + $this->parseSavepointRollBack('trans'.$this->transTimes) |
|
| 1734 | 1733 | ); |
| 1735 | 1734 | } |
| 1736 | 1735 | |
@@ -1754,7 +1753,7 @@ discard block |
||
| 1754 | 1753 | */ |
| 1755 | 1754 | protected function parseSavepoint($name) |
| 1756 | 1755 | { |
| 1757 | - return 'SAVEPOINT ' . $name; |
|
| 1756 | + return 'SAVEPOINT '.$name; |
|
| 1758 | 1757 | } |
| 1759 | 1758 | |
| 1760 | 1759 | /** |
@@ -1765,7 +1764,7 @@ discard block |
||
| 1765 | 1764 | */ |
| 1766 | 1765 | protected function parseSavepointRollBack($name) |
| 1767 | 1766 | { |
| 1768 | - return 'ROLLBACK TO SAVEPOINT ' . $name; |
|
| 1767 | + return 'ROLLBACK TO SAVEPOINT '.$name; |
|
| 1769 | 1768 | } |
| 1770 | 1769 | |
| 1771 | 1770 | /** |
@@ -1900,13 +1899,13 @@ discard block |
||
| 1900 | 1899 | { |
| 1901 | 1900 | if ($this->PDOStatement) { |
| 1902 | 1901 | $error = $this->PDOStatement->errorInfo(); |
| 1903 | - $error = $error[1] . ':' . $error[2]; |
|
| 1902 | + $error = $error[1].':'.$error[2]; |
|
| 1904 | 1903 | } else { |
| 1905 | 1904 | $error = ''; |
| 1906 | 1905 | } |
| 1907 | 1906 | |
| 1908 | 1907 | if ('' != $this->queryStr) { |
| 1909 | - $error .= "\n [ SQL语句 ] : " . $this->getLastsql(); |
|
| 1908 | + $error .= "\n [ SQL语句 ] : ".$this->getLastsql(); |
|
| 1910 | 1909 | } |
| 1911 | 1910 | |
| 1912 | 1911 | return $error; |
@@ -1983,10 +1982,10 @@ discard block |
||
| 1983 | 1982 | } |
| 1984 | 1983 | |
| 1985 | 1984 | // 未注册监听则记录到日志中 |
| 1986 | - $this->log('[ SQL ] ' . $sql . ' [ ' . $master . 'RunTime:' . $runtime . 's ]'); |
|
| 1985 | + $this->log('[ SQL ] '.$sql.' [ '.$master.'RunTime:'.$runtime.'s ]'); |
|
| 1987 | 1986 | |
| 1988 | 1987 | if (!empty($explain)) { |
| 1989 | - $this->log('[ EXPLAIN : ' . var_export($explain, true) . ' ]'); |
|
| 1988 | + $this->log('[ EXPLAIN : '.var_export($explain, true).' ]'); |
|
| 1990 | 1989 | } |
| 1991 | 1990 | } |
| 1992 | 1991 | } |
@@ -2136,14 +2135,14 @@ discard block |
||
| 2136 | 2135 | $data = $value[2]; |
| 2137 | 2136 | } |
| 2138 | 2137 | |
| 2139 | - $prefix = 'think:' . $this->getConfig('database') . '.'; |
|
| 2138 | + $prefix = 'think:'.$this->getConfig('database').'.'; |
|
| 2140 | 2139 | |
| 2141 | 2140 | if (isset($data)) { |
| 2142 | - return $prefix . $query->getTable() . '|' . $data; |
|
| 2141 | + return $prefix.$query->getTable().'|'.$data; |
|
| 2143 | 2142 | } |
| 2144 | 2143 | |
| 2145 | 2144 | try { |
| 2146 | - return md5($prefix . serialize($query->getOptions()) . serialize($query->getBind(false))); |
|
| 2145 | + return md5($prefix.serialize($query->getOptions()).serialize($query->getBind(false))); |
|
| 2147 | 2146 | } catch (\Exception $e) { |
| 2148 | 2147 | throw new Exception('closure not support cache(true)'); |
| 2149 | 2148 | } |
@@ -1812,9 +1812,11 @@ |
||
| 1812 | 1812 | |
| 1813 | 1813 | if ($this->config['rw_separate']) { |
| 1814 | 1814 | // 主从式采用读写分离 |
| 1815 | - if ($master) // 主服务器写入 |
|
| 1815 | + if ($master) { |
|
| 1816 | + // 主服务器写入 |
|
| 1816 | 1817 | { |
| 1817 | 1818 | $r = $m; |
| 1819 | + } |
|
| 1818 | 1820 | } elseif (is_numeric($this->config['slave_no'])) { |
| 1819 | 1821 | // 指定服务器读 |
| 1820 | 1822 | $r = $this->config['slave_no']; |
@@ -38,10 +38,10 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | protected function parseDsn($config) |
| 40 | 40 | { |
| 41 | - $dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname']; |
|
| 41 | + $dsn = 'sqlsrv:Database='.$config['database'].';Server='.$config['hostname']; |
|
| 42 | 42 | |
| 43 | 43 | if (!empty($config['hostport'])) { |
| 44 | - $dsn .= ',' . $config['hostport']; |
|
| 44 | + $dsn .= ','.$config['hostport']; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return $dsn; |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | if (is_null($field)) { |
| 161 | 161 | $field = '*'; |
| 162 | 162 | } elseif ($key && '*' != $field) { |
| 163 | - $field = $key . ',' . $field; |
|
| 163 | + $field = $key.','.$field; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | if (is_string($field)) { |