@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $body = $this->response()->body(); |
| 162 | 162 | $error_no = $this->response()->error_no(); |
| 163 | - $error=$this->response()->error(); |
|
| 163 | + $error = $this->response()->error(); |
|
| 164 | 164 | |
| 165 | 165 | if (!$error_no && !$error) { |
| 166 | 166 | $parse = $this->parseErrorClickHouse($body); |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | else { |
| 172 | 172 | $code = $this->response()->http_code(); |
| 173 | - $message = "HttpCode:" . $this->response()->http_code() . " ; ".$this->response()->error()." ;" . $body; |
|
| 173 | + $message = "HttpCode:" . $this->response()->http_code() . " ; " . $this->response()->error() . " ;" . $body; |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | else { |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | return false; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least','statistics'] as $key) { |
|
| 230 | + foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least', 'statistics'] as $key) { |
|
| 231 | 231 | if (isset($this->_rawData[$key])) { |
| 232 | 232 | $this->{$key} = $this->_rawData[$key]; |
| 233 | 233 | } |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | * @return array|mixed|null |
| 345 | 345 | * @throws Exception\TransportException |
| 346 | 346 | */ |
| 347 | - public function statistics($key=false) |
|
| 347 | + public function statistics($key = false) |
|
| 348 | 348 | { |
| 349 | 349 | $this->init(); |
| 350 | 350 | if ($key) |
@@ -167,13 +167,11 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | if ($parse) { |
| 169 | 169 | throw new DatabaseException($parse['message'] . "\nIN:" . $this->sql(), $parse['code']); |
| 170 | - } |
|
| 171 | - else { |
|
| 170 | + } else { |
|
| 172 | 171 | $code = $this->response()->http_code(); |
| 173 | 172 | $message = "HttpCode:" . $this->response()->http_code() . " ; ".$this->response()->error()." ;" . $body; |
| 174 | 173 | } |
| 175 | - } |
|
| 176 | - else { |
|
| 174 | + } else { |
|
| 177 | 175 | $code = $error_no; |
| 178 | 176 | $message = $this->response()->error(); |
| 179 | 177 | } |
@@ -349,8 +347,12 @@ discard block |
||
| 349 | 347 | $this->init(); |
| 350 | 348 | if ($key) |
| 351 | 349 | { |
| 352 | - if (!is_array($this->statistics)) return null; |
|
| 353 | - if (!isset($this->statistics[$key])) return null; |
|
| 350 | + if (!is_array($this->statistics)) { |
|
| 351 | + return null; |
|
| 352 | + } |
|
| 353 | + if (!isset($this->statistics[$key])) { |
|
| 354 | + return null; |
|
| 355 | + } |
|
| 354 | 356 | return $this->statistics[$key]; |
| 355 | 357 | } |
| 356 | 358 | return $this->statistics; |
@@ -394,8 +396,7 @@ discard block |
||
| 394 | 396 | if ($key) { |
| 395 | 397 | if (isset($this->array_data[0][$key])) { |
| 396 | 398 | return $this->array_data[0][$key]; |
| 397 | - } |
|
| 398 | - else { |
|
| 399 | + } else { |
|
| 399 | 400 | return null; |
| 400 | 401 | } |
| 401 | 402 | } |
@@ -489,16 +490,14 @@ discard block |
||
| 489 | 490 | { |
| 490 | 491 | if (is_array($path)) { |
| 491 | 492 | $keys = $path; |
| 492 | - } |
|
| 493 | - else { |
|
| 493 | + } else { |
|
| 494 | 494 | $args = func_get_args(); |
| 495 | 495 | array_shift($args); |
| 496 | 496 | |
| 497 | 497 | if (sizeof($args) < 2) { |
| 498 | 498 | $separator = '.'; |
| 499 | 499 | $keys = explode($separator, $path); |
| 500 | - } |
|
| 501 | - else { |
|
| 500 | + } else { |
|
| 502 | 501 | $keys = $args; |
| 503 | 502 | } |
| 504 | 503 | } |
@@ -510,14 +509,15 @@ discard block |
||
| 510 | 509 | |
| 511 | 510 | if (isset($arr[$key])) { |
| 512 | 511 | $val = $arr[$key]; |
| 513 | - } |
|
| 514 | - else { |
|
| 512 | + } else { |
|
| 515 | 513 | $val = $key; |
| 516 | 514 | } |
| 517 | 515 | |
| 518 | 516 | $tree = array($val => $tree); |
| 519 | 517 | } |
| 520 | - if (!is_array($tree)) return []; |
|
| 518 | + if (!is_array($tree)) { |
|
| 519 | + return []; |
|
| 520 | + } |
|
| 521 | 521 | return $tree; |
| 522 | 522 | } |
| 523 | 523 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * @var callable |
| 63 | 63 | */ |
| 64 | - private $xClickHouseProgress=null; |
|
| 64 | + private $xClickHouseProgress = null; |
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Http constructor. |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getUri() |
| 115 | 115 | { |
| 116 | - $proto='http'; |
|
| 117 | - if ($this->settings()->isHttps()) $proto='https'; |
|
| 116 | + $proto = 'http'; |
|
| 117 | + if ($this->settings()->isHttps()) $proto = 'https'; |
|
| 118 | 118 | |
| 119 | - return $proto.'://' . $this->_host . ':' . $this->_port; |
|
| 119 | + return $proto . '://' . $this->_host . ':' . $this->_port; |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | $new->timeOut($this->settings()->getTimeOut()); |
| 188 | - $new->connectTimeOut($this->_connectTimeOut)->keepAlive();// one sec |
|
| 188 | + $new->connectTimeOut($this->_connectTimeOut)->keepAlive(); // one sec |
|
| 189 | 189 | $new->verbose(boolval($this->_verbose)); |
| 190 | 190 | |
| 191 | 191 | return $new; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $request = $this->newRequest($extendinfo); |
| 280 | 280 | $request->url($url); |
| 281 | 281 | |
| 282 | - $request->setCallbackFunction(function (CurlerRequest $request) { |
|
| 282 | + $request->setCallbackFunction(function(CurlerRequest $request) { |
|
| 283 | 283 | fclose($request->getInfileHandle()); |
| 284 | 284 | }); |
| 285 | 285 | |
@@ -322,29 +322,29 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | public function __findXClickHouseProgress($handle) |
| 324 | 324 | { |
| 325 | - $code=curl_getinfo($handle,CURLINFO_HTTP_CODE); |
|
| 325 | + $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); |
|
| 326 | 326 | |
| 327 | 327 | // Search X-ClickHouse-Progress |
| 328 | - if ($code==200) { |
|
| 328 | + if ($code == 200) { |
|
| 329 | 329 | $response = curl_multi_getcontent($handle); |
| 330 | 330 | $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE); |
| 331 | 331 | if (!$header_size) return false; |
| 332 | 332 | |
| 333 | 333 | $header = substr($response, 0, $header_size); |
| 334 | 334 | if (!$header_size) return false; |
| 335 | - $pos=strrpos($header,'X-ClickHouse-Progress'); |
|
| 335 | + $pos = strrpos($header, 'X-ClickHouse-Progress'); |
|
| 336 | 336 | |
| 337 | 337 | if (!$pos) return false; |
| 338 | 338 | |
| 339 | - $last=substr($header,$pos); |
|
| 340 | - $data=@json_decode(str_ireplace('X-ClickHouse-Progress:','',$last),true); |
|
| 339 | + $last = substr($header, $pos); |
|
| 340 | + $data = @json_decode(str_ireplace('X-ClickHouse-Progress:', '', $last), true); |
|
| 341 | 341 | |
| 342 | 342 | if ($data && is_callable($this->xClickHouseProgress)) { |
| 343 | 343 | |
| 344 | - if (is_array($this->xClickHouseProgress)){ |
|
| 345 | - call_user_func_array($this->xClickHouseProgress,[$data]); |
|
| 344 | + if (is_array($this->xClickHouseProgress)) { |
|
| 345 | + call_user_func_array($this->xClickHouseProgress, [$data]); |
|
| 346 | 346 | } else { |
| 347 | - call_user_func($this->xClickHouseProgress,$data); |
|
| 347 | + call_user_func($this->xClickHouseProgress, $data); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
@@ -407,13 +407,13 @@ discard block |
||
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | |
| 410 | - $request->setResultFileHandle($fout, $isGz)->setCallbackFunction(function (CurlerRequest $request) { |
|
| 410 | + $request->setResultFileHandle($fout, $isGz)->setCallbackFunction(function(CurlerRequest $request) { |
|
| 411 | 411 | fclose($request->getResultFileHandle()); |
| 412 | 412 | }); |
| 413 | 413 | } |
| 414 | 414 | if ($this->xClickHouseProgress) |
| 415 | 415 | { |
| 416 | - $request->setFunctionProgress([$this,'__findXClickHouseProgress']); |
|
| 416 | + $request->setFunctionProgress([$this, '__findXClickHouseProgress']); |
|
| 417 | 417 | } |
| 418 | 418 | // --------------------------------------------------------------------------------- |
| 419 | 419 | return $request; |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | public function setProgressFunction(callable $callback) |
| 545 | 545 | { |
| 546 | - $this->xClickHouseProgress=$callback; |
|
| 546 | + $this->xClickHouseProgress = $callback; |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * @var CurlerResponse |
| 49 | 49 | */ |
| 50 | - private $resp=null; |
|
| 50 | + private $resp = null; |
|
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | 53 | * @var bool |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * @var callable |
| 79 | 79 | */ |
| 80 | - private $callback_function=null; |
|
| 80 | + private $callback_function = null; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * @var bool |
@@ -109,13 +109,13 @@ discard block |
||
| 109 | 109 | CURLOPT_SSL_VERIFYHOST => 0, |
| 110 | 110 | CURLOPT_SSL_VERIFYPEER => false, |
| 111 | 111 | CURLOPT_TIMEOUT => 10, |
| 112 | - CURLOPT_CONNECTTIMEOUT => 5, // Количество секунд ожидания при попытке соединения |
|
| 112 | + CURLOPT_CONNECTTIMEOUT => 5, // Количество секунд ожидания при попытке соединения |
|
| 113 | 113 | CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
| 114 | 114 | CURLOPT_MAXREDIRS => 10, |
| 115 | 115 | CURLOPT_HEADER => TRUE, |
| 116 | 116 | CURLOPT_FOLLOWLOCATION => TRUE, |
| 117 | - CURLOPT_AUTOREFERER => 1, // при редиректе подставлять в «Referer:» значение из «Location:» |
|
| 118 | - CURLOPT_BINARYTRANSFER => 1, // передавать в binary-safe |
|
| 117 | + CURLOPT_AUTOREFERER => 1, // при редиректе подставлять в «Referer:» значение из «Location:» |
|
| 118 | + CURLOPT_BINARYTRANSFER => 1, // передавать в binary-safe |
|
| 119 | 119 | CURLOPT_RETURNTRANSFER => TRUE, |
| 120 | 120 | CURLOPT_USERAGENT => 'smi2/PHPClickHouse/client', |
| 121 | 121 | ); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | public function setReadFunction($callback) |
| 240 | 240 | { |
| 241 | - $this->options[CURLOPT_READFUNCTION]=$callback; |
|
| 241 | + $this->options[CURLOPT_READFUNCTION] = $callback; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | */ |
| 364 | 364 | public function getHeaders() |
| 365 | 365 | { |
| 366 | - $head=[]; |
|
| 366 | + $head = []; |
|
| 367 | 367 | foreach ($this->headers as $key=>$value) |
| 368 | - $head[]= sprintf("%s: %s", $key, $value); |
|
| 368 | + $head[] = sprintf("%s: %s", $key, $value); |
|
| 369 | 369 | return $head; |
| 370 | 370 | } |
| 371 | 371 | |
@@ -640,8 +640,8 @@ discard block |
||
| 640 | 640 | throw new \Exception('setFunctionProgress not is_callable'); |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | - $this->option(CURLOPT_NOPROGRESS,false); |
|
| 644 | - $this->option(CURLOPT_PROGRESSFUNCTION,$callback); // version 5.5.0 |
|
| 643 | + $this->option(CURLOPT_NOPROGRESS, false); |
|
| 644 | + $this->option(CURLOPT_PROGRESSFUNCTION, $callback); // version 5.5.0 |
|
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | if ($this->options[CURLOPT_VERBOSE]) { |
| 707 | - echo "\n-----------BODY REQUEST----------\n".$curl_opt[CURLOPT_POSTFIELDS]."\n------END--------\n"; |
|
| 707 | + echo "\n-----------BODY REQUEST----------\n" . $curl_opt[CURLOPT_POSTFIELDS] . "\n------END--------\n"; |
|
| 708 | 708 | } |
| 709 | 709 | curl_setopt_array($this->handle, $curl_opt); |
| 710 | 710 | return true; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * @var int|float |
| 44 | 44 | */ |
| 45 | - private $scanTimeOut=10; |
|
| 45 | + private $scanTimeOut = 10; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @var array |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @var array |
| 79 | 79 | */ |
| 80 | - private $_table_size_cache=[]; |
|
| 80 | + private $_table_size_cache = []; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Cluster constructor. |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | // @todo : rewrite total_replicas=1 если кластер без реплики , нужно проверять какой класте и сколько в нем реплик |
| 193 | 193 | // if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);} |
| 194 | - if ($this->softCheck ) |
|
| 194 | + if ($this->softCheck) |
|
| 195 | 195 | { |
| 196 | 196 | if (!$ok) break; |
| 197 | 197 | continue; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $statementsClusters[$node]->getRequest()->setDnsCache(0)->timeOut($this->scanTimeOut)->connectTimeOut($this->scanTimeOut); |
| 263 | 263 | } |
| 264 | 264 | $this->defaultClient()->executeAsync(); |
| 265 | - $tables=[]; |
|
| 265 | + $tables = []; |
|
| 266 | 266 | |
| 267 | 267 | foreach ($this->nodes as $node) { |
| 268 | 268 | |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | try { |
| 271 | 271 | $r = $statementsReplicas[$node]->rows(); |
| 272 | 272 | foreach ($r as $row) { |
| 273 | - $tables[$row['database']][$row['table']][$node] =$row; |
|
| 273 | + $tables[$row['database']][$row['table']][$node] = $row; |
|
| 274 | 274 | } |
| 275 | 275 | $result['replicas'][$node] = $r; |
| 276 | - } catch (\Exception $E) { |
|
| 276 | + }catch (\Exception $E) { |
|
| 277 | 277 | $result['replicas'][$node] = false; |
| 278 | 278 | $badNodes[$node] = $E->getMessage(); |
| 279 | 279 | $this->error[] = 'statementsReplicas:' . $E->getMessage(); |
| 280 | 280 | } |
| 281 | 281 | // --------------------------------------------------------------------------------------------------- |
| 282 | - $hosts=[]; |
|
| 282 | + $hosts = []; |
|
| 283 | 283 | |
| 284 | 284 | try { |
| 285 | 285 | $c = $statementsClusters[$node]->rows(); |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | ]; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - } catch (\Exception $E) { |
|
| 298 | + }catch (\Exception $E) { |
|
| 299 | 299 | $result['clusters'][$node] = false; |
| 300 | 300 | |
| 301 | 301 | $this->error[] = 'clusters:' . $E->getMessage(); |
@@ -363,22 +363,22 @@ discard block |
||
| 363 | 363 | * @return Client |
| 364 | 364 | * @throws Exception\TransportException |
| 365 | 365 | */ |
| 366 | - public function clientLike($cluster,$ip_addr_like) |
|
| 366 | + public function clientLike($cluster, $ip_addr_like) |
|
| 367 | 367 | { |
| 368 | - $nodes_check=$this->nodes; |
|
| 369 | - $nodes=$this->getClusterNodes($cluster); |
|
| 370 | - $list_ips_need=explode(';',$ip_addr_like); |
|
| 371 | - $find=false; |
|
| 372 | - foreach($list_ips_need as $like) |
|
| 368 | + $nodes_check = $this->nodes; |
|
| 369 | + $nodes = $this->getClusterNodes($cluster); |
|
| 370 | + $list_ips_need = explode(';', $ip_addr_like); |
|
| 371 | + $find = false; |
|
| 372 | + foreach ($list_ips_need as $like) |
|
| 373 | 373 | { |
| 374 | 374 | foreach ($nodes as $node) |
| 375 | 375 | { |
| 376 | 376 | |
| 377 | - if (stripos($node,$like)!==false) |
|
| 377 | + if (stripos($node, $like) !== false) |
|
| 378 | 378 | { |
| 379 | - if (in_array($node,$nodes_check)) |
|
| 379 | + if (in_array($node, $nodes_check)) |
|
| 380 | 380 | { |
| 381 | - $find=$node; |
|
| 381 | + $find = $node; |
|
| 382 | 382 | } |
| 383 | 383 | else |
| 384 | 384 | { |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | if ($find) break; |
| 392 | 392 | } |
| 393 | - if (!$find){ |
|
| 394 | - $find=$nodes[0]; |
|
| 393 | + if (!$find) { |
|
| 394 | + $find = $nodes[0]; |
|
| 395 | 395 | } |
| 396 | 396 | return $this->client($find); |
| 397 | 397 | } |
@@ -471,10 +471,10 @@ discard block |
||
| 471 | 471 | * @return array |
| 472 | 472 | * @throws Exception\TransportException |
| 473 | 473 | */ |
| 474 | - public function getTables($resultDetail=false) |
|
| 474 | + public function getTables($resultDetail = false) |
|
| 475 | 475 | { |
| 476 | 476 | $this->connect(); |
| 477 | - $list=[]; |
|
| 477 | + $list = []; |
|
| 478 | 478 | foreach ($this->tables as $db_name=>$tables) |
| 479 | 479 | { |
| 480 | 480 | foreach ($tables as $table_name=>$nodes) |
@@ -482,11 +482,11 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | if ($resultDetail) |
| 484 | 484 | { |
| 485 | - $list[$db_name.'.'.$table_name]=$nodes; |
|
| 485 | + $list[$db_name . '.' . $table_name] = $nodes; |
|
| 486 | 486 | } |
| 487 | 487 | else |
| 488 | 488 | { |
| 489 | - $list[$db_name.'.'.$table_name]=array_keys($nodes); |
|
| 489 | + $list[$db_name . '.' . $table_name] = array_keys($nodes); |
|
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | } |
@@ -503,24 +503,24 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | public function getSizeTable($database_table) |
| 505 | 505 | { |
| 506 | - $list=[]; |
|
| 507 | - $nodes=$this->getNodesByTable($database_table); |
|
| 506 | + $list = []; |
|
| 507 | + $nodes = $this->getNodesByTable($database_table); |
|
| 508 | 508 | // scan need node`s |
| 509 | 509 | foreach ($nodes as $node) |
| 510 | 510 | { |
| 511 | 511 | if (empty($this->_table_size_cache[$node])) |
| 512 | 512 | { |
| 513 | - $this->_table_size_cache[$node]=$this->client($node)->tablesSize(true); |
|
| 513 | + $this->_table_size_cache[$node] = $this->client($node)->tablesSize(true); |
|
| 514 | 514 | } |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - $sizes=[]; |
|
| 517 | + $sizes = []; |
|
| 518 | 518 | foreach ($this->_table_size_cache as $node=>$rows) |
| 519 | 519 | { |
| 520 | 520 | foreach ($rows as $row) |
| 521 | 521 | { |
| 522 | - $sizes[$row['database'].'.'.$row['table']][$node]=$row; |
|
| 523 | - @$sizes[$row['database'].'.'.$row['table']]['total']['sizebytes']+=$row['sizebytes']; |
|
| 522 | + $sizes[$row['database'] . '.' . $row['table']][$node] = $row; |
|
| 523 | + @$sizes[$row['database'] . '.' . $row['table']]['total']['sizebytes'] += $row['sizebytes']; |
|
| 524 | 524 | |
| 525 | 525 | |
| 526 | 526 | |
@@ -542,17 +542,17 @@ discard block |
||
| 542 | 542 | * @return array |
| 543 | 543 | * @throws Exception\TransportException |
| 544 | 544 | */ |
| 545 | - public function truncateTable($database_table,$timeOut=2000) |
|
| 545 | + public function truncateTable($database_table, $timeOut = 2000) |
|
| 546 | 546 | { |
| 547 | - $out=[]; |
|
| 548 | - list($db,$table)=explode('.',$database_table); |
|
| 549 | - $nodes=$this->getMasterNodeForTable($database_table); |
|
| 547 | + $out = []; |
|
| 548 | + list($db, $table) = explode('.', $database_table); |
|
| 549 | + $nodes = $this->getMasterNodeForTable($database_table); |
|
| 550 | 550 | // scan need node`s |
| 551 | 551 | foreach ($nodes as $node) |
| 552 | 552 | { |
| 553 | - $def=$this->client($node)->getTimeout(); |
|
| 553 | + $def = $this->client($node)->getTimeout(); |
|
| 554 | 554 | $this->client($node)->database($db)->setTimeout($timeOut); |
| 555 | - $out[$node]=$this->client($node)->truncateTable($table); |
|
| 555 | + $out[$node] = $this->client($node)->truncateTable($table); |
|
| 556 | 556 | $this->client($node)->setTimeout($def); |
| 557 | 557 | } |
| 558 | 558 | return $out; |
@@ -567,15 +567,15 @@ discard block |
||
| 567 | 567 | */ |
| 568 | 568 | public function getMasterNodeForTable($database_table) |
| 569 | 569 | { |
| 570 | - $list=$this->getTables(true); |
|
| 570 | + $list = $this->getTables(true); |
|
| 571 | 571 | |
| 572 | 572 | if (empty($list[$database_table])) return []; |
| 573 | 573 | |
| 574 | 574 | |
| 575 | - $result=[]; |
|
| 575 | + $result = []; |
|
| 576 | 576 | foreach ($list[$database_table] as $node=>$row) |
| 577 | 577 | { |
| 578 | - if ($row['is_leader']) $result[]=$node; |
|
| 578 | + if ($row['is_leader']) $result[] = $node; |
|
| 579 | 579 | } |
| 580 | 580 | return $result; |
| 581 | 581 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | public function getNodesByTable($database_table) |
| 590 | 590 | { |
| 591 | - $list=$this->getTables(); |
|
| 591 | + $list = $this->getTables(); |
|
| 592 | 592 | if (empty($list[$database_table])) { |
| 593 | 593 | throw new QueryException('Not find :' . $database_table); |
| 594 | 594 | } |
@@ -47,7 +47,9 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function get($key) |
| 49 | 49 | { |
| 50 | - if (!$this->is($key)) return null; |
|
| 50 | + if (!$this->is($key)) { |
|
| 51 | + return null; |
|
| 52 | + } |
|
| 51 | 53 | return $this->settings[$key]; |
| 52 | 54 | } |
| 53 | 55 | |
@@ -153,7 +155,9 @@ discard block |
||
| 153 | 155 | */ |
| 154 | 156 | public function getSessionId() |
| 155 | 157 | { |
| 156 | - if (empty($this->settings['session_id'])) return false; |
|
| 158 | + if (empty($this->settings['session_id'])) { |
|
| 159 | + return false; |
|
| 160 | + } |
|
| 157 | 161 | return $this->get('session_id'); |
| 158 | 162 | } |
| 159 | 163 | |