@@ -29,8 +29,7 @@ |
||
29 | 29 | if ($else) |
30 | 30 | { |
31 | 31 | list($condition, $preset ,$variable, $content_true, $content_false) = $matches; |
32 | - } |
|
33 | - else |
|
32 | + } else |
|
34 | 33 | { |
35 | 34 | list($condition, $preset ,$variable, $content_true) = $matches; |
36 | 35 | } |
@@ -295,8 +295,7 @@ discard block |
||
295 | 295 | if (!$useSessionId) |
296 | 296 | { |
297 | 297 | $this->settings()->makeSessionId(); |
298 | - } |
|
299 | - else |
|
298 | + } else |
|
300 | 299 | { |
301 | 300 | $this->settings()->session_id($useSessionId); |
302 | 301 | } |
@@ -415,7 +414,9 @@ discard block |
||
415 | 414 | */ |
416 | 415 | public function progressFunction($callback) |
417 | 416 | { |
418 | - if (!is_callable($callback)) throw new \InvalidArgumentException('Not is_callable progressFunction'); |
|
417 | + if (!is_callable($callback)) { |
|
418 | + throw new \InvalidArgumentException('Not is_callable progressFunction'); |
|
419 | + } |
|
419 | 420 | |
420 | 421 | if (!$this->settings()->is('send_progress_in_http_headers')) |
421 | 422 | { |
@@ -540,7 +541,7 @@ discard block |
||
540 | 541 | } |
541 | 542 | $preparedValues[] = array_values($row); |
542 | 543 | } |
543 | - }else{ //одна строка |
|
544 | + } else{ //одна строка |
|
544 | 545 | $preparedFields = array_keys($values); |
545 | 546 | $preparedValues = [array_values($values)]; |
546 | 547 | } |
@@ -609,8 +610,7 @@ discard block |
||
609 | 610 | { |
610 | 611 | $sql = 'INSERT INTO ' . $table_name . ' FORMAT '.$format; |
611 | 612 | |
612 | - } |
|
613 | - else |
|
613 | + } else |
|
614 | 614 | { |
615 | 615 | $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT '.$format; |
616 | 616 | |
@@ -654,8 +654,7 @@ discard block |
||
654 | 654 | { |
655 | 655 | $sql = 'INSERT INTO ' . $table_name . ' FORMAT '.$format; |
656 | 656 | |
657 | - } |
|
658 | - else |
|
657 | + } else |
|
659 | 658 | { |
660 | 659 | $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT '.$format; |
661 | 660 |
@@ -353,8 +353,9 @@ discard block |
||
353 | 353 | public function getHeaders() |
354 | 354 | { |
355 | 355 | $head=[]; |
356 | - foreach ($this->headers as $key=>$value) |
|
357 | - $head[]= sprintf("%s: %s", $key, $value); |
|
356 | + foreach ($this->headers as $key=>$value) { |
|
357 | + $head[]= sprintf("%s: %s", $key, $value); |
|
358 | + } |
|
358 | 359 | return $head; |
359 | 360 | } |
360 | 361 | |
@@ -394,8 +395,7 @@ discard block |
||
394 | 395 | if ($flag) { |
395 | 396 | $this->_httpCompression = $flag; |
396 | 397 | $this->options[CURLOPT_ENCODING] = 'gzip'; |
397 | - } |
|
398 | - else |
|
398 | + } else |
|
399 | 399 | { |
400 | 400 | $this->_httpCompression = false; |
401 | 401 | unset($this->options[CURLOPT_ENCODING]); |
@@ -176,8 +176,7 @@ discard block |
||
176 | 176 | foreach (explode("\r\n", $header_text) as $i => $line) { |
177 | 177 | if ($i === 0) { |
178 | 178 | $headers['http_code'] = $line; |
179 | - } |
|
180 | - else { |
|
179 | + } else { |
|
181 | 180 | $r = explode(': ', $line); |
182 | 181 | if (sizeof($r) == 2) { |
183 | 182 | $headers[$r[0]] = $r[1]; |
@@ -354,8 +353,7 @@ discard block |
||
354 | 353 | if (sizeof($add)) { |
355 | 354 | if ($canAdd >= sizeof($add)) { |
356 | 355 | $ll = $add; |
357 | - } |
|
358 | - else { |
|
356 | + } else { |
|
359 | 357 | $ll = array_rand($add, $canAdd); |
360 | 358 | if (!is_array($ll)) { |
361 | 359 | $ll = array($ll => $ll); |
@@ -114,7 +114,9 @@ discard block |
||
114 | 114 | public function getUri() |
115 | 115 | { |
116 | 116 | $proto='http'; |
117 | - if ($this->settings()->isHttps()) $proto='https'; |
|
117 | + if ($this->settings()->isHttps()) { |
|
118 | + $proto='https'; |
|
119 | + } |
|
118 | 120 | |
119 | 121 | return $proto.'://' . $this->_host . ':' . $this->_port; |
120 | 122 | } |
@@ -328,13 +330,19 @@ discard block |
||
328 | 330 | if ($code==200) { |
329 | 331 | $response = curl_multi_getcontent($handle); |
330 | 332 | $header_size = curl_getinfo($handle, CURLINFO_HEADER_SIZE); |
331 | - if (!$header_size) return false; |
|
333 | + if (!$header_size) { |
|
334 | + return false; |
|
335 | + } |
|
332 | 336 | |
333 | 337 | $header = substr($response, 0, $header_size); |
334 | - if (!$header_size) return false; |
|
338 | + if (!$header_size) { |
|
339 | + return false; |
|
340 | + } |
|
335 | 341 | $pos=strrpos($header,'X-ClickHouse-Progress'); |
336 | 342 | |
337 | - if (!$pos) return false; |
|
343 | + if (!$pos) { |
|
344 | + return false; |
|
345 | + } |
|
338 | 346 | |
339 | 347 | $last=substr($header,$pos); |
340 | 348 | $data=@json_decode(str_ireplace('X-ClickHouse-Progress:','',$last),true); |
@@ -193,7 +193,9 @@ discard block |
||
193 | 193 | // if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);} |
194 | 194 | if ($this->softCheck ) |
195 | 195 | { |
196 | - if (!$ok) break; |
|
196 | + if (!$ok) { |
|
197 | + break; |
|
198 | + } |
|
197 | 199 | continue; |
198 | 200 | } |
199 | 201 | |
@@ -209,7 +211,9 @@ discard block |
||
209 | 211 | $ok = false; |
210 | 212 | $this->error[] = 'log_max_index : ' . json_encode($replica); |
211 | 213 | } |
212 | - if (!$ok) break; |
|
214 | + if (!$ok) { |
|
215 | + break; |
|
216 | + } |
|
213 | 217 | } |
214 | 218 | return $ok; |
215 | 219 | } |
@@ -308,7 +312,9 @@ discard block |
||
308 | 312 | // Let's check that replication goes well |
309 | 313 | $rIsOk = $this->isReplicasWork($result['replicas'][$node]); |
310 | 314 | $result['replicasIsOk'][$node] = $rIsOk; |
311 | - if (!$rIsOk) $replicasIsOk = false; |
|
315 | + if (!$rIsOk) { |
|
316 | + $replicasIsOk = false; |
|
317 | + } |
|
312 | 318 | // --------------------------------------------------------------------------------------------------- |
313 | 319 | } |
314 | 320 | |
@@ -328,7 +334,9 @@ discard block |
||
328 | 334 | $this->error[] = 'Have bad node : ' . json_encode($this->badNodes); |
329 | 335 | $this->replicasIsOk = false; |
330 | 336 | } |
331 | - if (!sizeof($this->error)) $this->error = false; |
|
337 | + if (!sizeof($this->error)) { |
|
338 | + $this->error = false; |
|
339 | + } |
|
332 | 340 | $this->resultScan = $result; |
333 | 341 | // @todo : We connect to everyone in the DNS list, we need to decry that the requests were returned by all the hosts to which we connected |
334 | 342 | return $this; |
@@ -376,16 +384,19 @@ discard block |
||
376 | 384 | if (in_array($node,$nodes_check)) |
377 | 385 | { |
378 | 386 | $find=$node; |
379 | - } |
|
380 | - else |
|
387 | + } else |
|
381 | 388 | { |
382 | 389 | // node exists on cluster, but not check |
383 | 390 | } |
384 | 391 | |
385 | 392 | } |
386 | - if ($find) break; |
|
393 | + if ($find) { |
|
394 | + break; |
|
395 | + } |
|
396 | + } |
|
397 | + if ($find) { |
|
398 | + break; |
|
387 | 399 | } |
388 | - if ($find) break; |
|
389 | 400 | } |
390 | 401 | if (!$find){ |
391 | 402 | $find=$nodes[0]; |
@@ -435,7 +446,9 @@ discard block |
||
435 | 446 | public function getClusterInfoTable($cluster) |
436 | 447 | { |
437 | 448 | $this->connect(); |
438 | - if (empty($this->resultScan['cluster.list'][$cluster])) throw new QueryException('Cluster not find:' . $cluster); |
|
449 | + if (empty($this->resultScan['cluster.list'][$cluster])) { |
|
450 | + throw new QueryException('Cluster not find:' . $cluster); |
|
451 | + } |
|
439 | 452 | return $this->resultScan['cluster.list'][$cluster]; |
440 | 453 | } |
441 | 454 | |
@@ -474,8 +487,7 @@ discard block |
||
474 | 487 | if ($resultDetail) |
475 | 488 | { |
476 | 489 | $list[$db_name.'.'.$table_name]=$nodes; |
477 | - } |
|
478 | - else |
|
490 | + } else |
|
479 | 491 | { |
480 | 492 | $list[$db_name.'.'.$table_name]=array_keys($nodes); |
481 | 493 | } |
@@ -557,13 +569,17 @@ discard block |
||
557 | 569 | { |
558 | 570 | $list=$this->getTables(true); |
559 | 571 | |
560 | - if (empty($list[$database_table])) return []; |
|
572 | + if (empty($list[$database_table])) { |
|
573 | + return []; |
|
574 | + } |
|
561 | 575 | |
562 | 576 | |
563 | 577 | $result=[]; |
564 | 578 | foreach ($list[$database_table] as $node=>$row) |
565 | 579 | { |
566 | - if ($row['is_leader']) $result[]=$node; |
|
580 | + if ($row['is_leader']) { |
|
581 | + $result[]=$node; |
|
582 | + } |
|
567 | 583 | } |
568 | 584 | return $result; |
569 | 585 | } |
@@ -49,7 +49,9 @@ discard block |
||
49 | 49 | private function applyFormatQuery() |
50 | 50 | { |
51 | 51 | // FORMAT\s(\w)*$ |
52 | - if (null === $this->format) return false; |
|
52 | + if (null === $this->format) { |
|
53 | + return false; |
|
54 | + } |
|
53 | 55 | $supportFormats= |
54 | 56 | "FORMAT\\s+TSV|FORMAT\\s+TSVRaw|FORMAT\\s+TSVWithNames|FORMAT\\s+TSVWithNamesAndTypes|FORMAT\\s+Vertical|FORMAT\\s+JSONCompact|FORMAT\\s+JSONEachRow|FORMAT\\s+TSKV|FORMAT\\s+TabSeparatedWithNames|FORMAT\\s+TabSeparatedWithNamesAndTypes|FORMAT\\s+TabSeparatedRaw|FORMAT\\s+BlockTabSeparated|FORMAT\\s+CSVWithNames|FORMAT\\s+CSV|FORMAT\\s+JSON|FORMAT\\s+TabSeparated"; |
55 | 57 | |
@@ -63,8 +65,7 @@ discard block |
||
63 | 65 | $this->format=trim(str_ireplace('format','',$matches[0][0])); |
64 | 66 | |
65 | 67 | } |
66 | - } |
|
67 | - else { |
|
68 | + } else { |
|
68 | 69 | $this->sql = $this->sql . ' FORMAT ' . $this->format; |
69 | 70 | } |
70 | 71 |
@@ -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 |
@@ -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 | } |