@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | $tables[$row['database']][$row['table']][$node] = $row; |
278 | 278 | } |
279 | 279 | $result['replicas'][$node] = $r; |
280 | - }catch (\Exception $E) { |
|
280 | + } catch (\Exception $E) { |
|
281 | 281 | $result['replicas'][$node] = false; |
282 | 282 | $badNodes[$node] = $E->getMessage(); |
283 | 283 | $this->error[] = 'statementsReplicas:' . $E->getMessage(); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | ]; |
300 | 300 | } |
301 | 301 | |
302 | - }catch (\Exception $E) { |
|
302 | + } catch (\Exception $E) { |
|
303 | 303 | $result['clusters'][$node] = false; |
304 | 304 | |
305 | 305 | $this->error[] = 'clusters:' . $E->getMessage(); |
@@ -9,7 +9,7 @@ |
||
9 | 9 | class StreamWrite extends Stream |
10 | 10 | { |
11 | 11 | |
12 | - public function __construct( $source) |
|
12 | + public function __construct($source) |
|
13 | 13 | { |
14 | 14 | |
15 | 15 | parent::__construct($source); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | * @param CurlerRequest $request |
32 | 32 | * @param CurlerRolling|null $curlerRolling |
33 | 33 | */ |
34 | - public function __construct($source, CurlerRequest $request, $curlerRolling=null) |
|
34 | + public function __construct($source, CurlerRequest $request, $curlerRolling = null) |
|
35 | 35 | { |
36 | 36 | if (!is_resource($source)) { |
37 | 37 | throw new \InvalidArgumentException('Argument $source must be resource'); |
@@ -293,7 +293,7 @@ |
||
293 | 293 | |
294 | 294 | if (stripos($format, 'json') !== false) |
295 | 295 | { |
296 | - if (stripos($format,'JSONEachRow')===false) |
|
296 | + if (stripos($format, 'JSONEachRow') === false) |
|
297 | 297 | return $this->json(); |
298 | 298 | } |
299 | 299 | return $this->body(); |
@@ -293,8 +293,9 @@ |
||
293 | 293 | |
294 | 294 | if (stripos($format, 'json') !== false) |
295 | 295 | { |
296 | - if (stripos($format,'JSONEachRow')===false) |
|
297 | - return $this->json(); |
|
296 | + if (stripos($format,'JSONEachRow')===false) { |
|
297 | + return $this->json(); |
|
298 | + } |
|
298 | 299 | } |
299 | 300 | return $this->body(); |
300 | 301 |
@@ -650,8 +650,9 @@ |
||
650 | 650 | } |
651 | 651 | return $response; |
652 | 652 | } finally { |
653 | - if ($streamRW->isWrite()) |
|
654 | - fclose($stream); |
|
653 | + if ($streamRW->isWrite()) { |
|
654 | + fclose($stream); |
|
655 | + } |
|
655 | 656 | } |
656 | 657 | |
657 | 658 |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | $proto = 'https'; |
121 | 121 | } |
122 | 122 | $uri = $proto . '://' . $this->_host; |
123 | - if (stripos($this->_host,'/')!==false || stripos($this->_host,':')!==false) { |
|
123 | + if (stripos($this->_host, '/') !== false || stripos($this->_host, ':') !== false) { |
|
124 | 124 | return $uri; |
125 | 125 | } |
126 | - if (intval($this->_port)>0) { |
|
126 | + if (intval($this->_port) > 0) { |
|
127 | 127 | return $uri . ':' . $this->_port; |
128 | 128 | } |
129 | 129 | return $uri; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | { |
249 | 249 | |
250 | 250 | if ($sql instanceof Query) { |
251 | - $query=$sql; |
|
251 | + $query = $sql; |
|
252 | 252 | } else { |
253 | 253 | $query = new Query($sql); |
254 | 254 | } |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | * @return Statement |
611 | 611 | * @throws \ClickHouseDB\Exception\TransportException |
612 | 612 | */ |
613 | - private function streaming(Stream $streamRW,CurlerRequest $request) |
|
613 | + private function streaming(Stream $streamRW, CurlerRequest $request) |
|
614 | 614 | { |
615 | - $callable=$streamRW->getClosure(); |
|
616 | - $stream=$streamRW->getStream(); |
|
615 | + $callable = $streamRW->getClosure(); |
|
616 | + $stream = $streamRW->getStream(); |
|
617 | 617 | |
618 | 618 | |
619 | 619 | |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | if ($streamRW->isWrite()) |
625 | 625 | { |
626 | 626 | |
627 | - $callable = function ($ch, $fd, $length) use ($stream) { |
|
627 | + $callable = function($ch, $fd, $length) use ($stream) { |
|
628 | 628 | return ($line = fread($stream, $length)) ? $line : ''; |
629 | 629 | }; |
630 | 630 | } else { |
631 | - $callable = function ($ch, $fd) use ($stream) { |
|
631 | + $callable = function($ch, $fd) use ($stream) { |
|
632 | 632 | return fwrite($stream, $fd); |
633 | 633 | }; |
634 | 634 | } |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | } |
664 | 664 | |
665 | 665 | |
666 | - $this->_curler->execOne($request,true); |
|
666 | + $this->_curler->execOne($request, true); |
|
667 | 667 | $response = new Statement($request); |
668 | 668 | if ($response->isError()) { |
669 | 669 | $response->error(); |
@@ -685,11 +685,11 @@ discard block |
||
685 | 685 | * @return Statement |
686 | 686 | * @throws \ClickHouseDB\Exception\TransportException |
687 | 687 | */ |
688 | - public function streamRead(Stream $streamRead,$sql,$bindings=[]) |
|
688 | + public function streamRead(Stream $streamRead, $sql, $bindings = []) |
|
689 | 689 | { |
690 | - $sql=$this->prepareQuery($sql,$bindings); |
|
691 | - $request=$this->getRequestRead($sql); |
|
692 | - return $this->streaming($streamRead,$request); |
|
690 | + $sql = $this->prepareQuery($sql, $bindings); |
|
691 | + $request = $this->getRequestRead($sql); |
|
692 | + return $this->streaming($streamRead, $request); |
|
693 | 693 | |
694 | 694 | } |
695 | 695 | |
@@ -700,10 +700,10 @@ discard block |
||
700 | 700 | * @return Statement |
701 | 701 | * @throws \ClickHouseDB\Exception\TransportException |
702 | 702 | */ |
703 | - public function streamWrite(Stream $streamWrite,$sql,$bindings=[]) |
|
703 | + public function streamWrite(Stream $streamWrite, $sql, $bindings = []) |
|
704 | 704 | { |
705 | - $sql=$this->prepareQuery($sql,$bindings); |
|
705 | + $sql = $this->prepareQuery($sql, $bindings); |
|
706 | 706 | $request = $this->writeStreamData($sql); |
707 | - return $this->streaming($streamWrite,$request); |
|
707 | + return $this->streaming($streamWrite, $request); |
|
708 | 708 | } |
709 | 709 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var bool |
17 | 17 | */ |
18 | - private $gzip=false; |
|
18 | + private $gzip = false; |
|
19 | 19 | /** |
20 | 20 | * @var null|callable |
21 | 21 | */ |
22 | - private $callable=null; |
|
22 | + private $callable = null; |
|
23 | 23 | /** |
24 | 24 | * @param resource $source |
25 | 25 | */ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function closure(callable $callable) |
62 | 62 | { |
63 | - $this->callable=$callable; |
|
63 | + $this->callable = $callable; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function enableGzipHeader() |
70 | 70 | { |
71 | - $this->gzip=true; |
|
71 | + $this->gzip = true; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | } |
@@ -219,15 +219,15 @@ discard block |
||
219 | 219 | $this->_init = true; |
220 | 220 | return false; |
221 | 221 | } |
222 | - $data=[]; |
|
222 | + $data = []; |
|
223 | 223 | foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least', 'statistics'] as $key) { |
224 | 224 | |
225 | 225 | if (isset($this->_rawData[$key])) { |
226 | - if ($key=='data') |
|
226 | + if ($key == 'data') |
|
227 | 227 | { |
228 | - $data=$this->_rawData[$key]; |
|
228 | + $data = $this->_rawData[$key]; |
|
229 | 229 | } |
230 | - else{ |
|
230 | + else { |
|
231 | 231 | $this->{$key} = $this->_rawData[$key]; |
232 | 232 | } |
233 | 233 | |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | throw new QueryException('Can`t find meta'); |
239 | 239 | } |
240 | 240 | |
241 | - $isJSONCompact=(stripos($this->format,'JSONCompact')!==false?true:false); |
|
241 | + $isJSONCompact = (stripos($this->format, 'JSONCompact') !== false ?true:false); |
|
242 | 242 | $this->array_data = []; |
243 | 243 | foreach ($data as $rows) { |
244 | 244 | $r = []; |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | if ($isJSONCompact) |
248 | 248 | { |
249 | - $r[]=$rows; |
|
249 | + $r[] = $rows; |
|
250 | 250 | } |
251 | 251 | else { |
252 | 252 | foreach ($this->meta as $meta) { |
@@ -226,8 +226,7 @@ discard block |
||
226 | 226 | if ($key=='data') |
227 | 227 | { |
228 | 228 | $data=$this->_rawData[$key]; |
229 | - } |
|
230 | - else{ |
|
229 | + } else{ |
|
231 | 230 | $this->{$key} = $this->_rawData[$key]; |
232 | 231 | } |
233 | 232 | |
@@ -247,8 +246,7 @@ discard block |
||
247 | 246 | if ($isJSONCompact) |
248 | 247 | { |
249 | 248 | $r[]=$rows; |
250 | - } |
|
251 | - else { |
|
249 | + } else { |
|
252 | 250 | foreach ($this->meta as $meta) { |
253 | 251 | $r[$meta['name']] = $rows[$meta['name']]; |
254 | 252 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function execLoopWait() |
145 | 145 | { |
146 | 146 | $c = 0; |
147 | - $count=0; |
|
147 | + $count = 0; |
|
148 | 148 | // add all tasks |
149 | 149 | do { |
150 | 150 | $this->exec(); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $loop = $this->countActive(); |
153 | 153 | $pend = $this->countPending(); |
154 | 154 | |
155 | - $count=$loop+$pend; |
|
155 | + $count = $loop + $pend; |
|
156 | 156 | $c++; |
157 | 157 | |
158 | 158 | if ($c > 20000) { |
@@ -59,19 +59,19 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __construct(array $connectParams, array $settings = []) |
61 | 61 | { |
62 | - if (! isset($connectParams['username'])) { |
|
62 | + if (!isset($connectParams['username'])) { |
|
63 | 63 | throw new \InvalidArgumentException('not set username'); |
64 | 64 | } |
65 | 65 | |
66 | - if (! isset($connectParams['password'])) { |
|
66 | + if (!isset($connectParams['password'])) { |
|
67 | 67 | throw new \InvalidArgumentException('not set password'); |
68 | 68 | } |
69 | 69 | |
70 | - if (! isset($connectParams['port'])) { |
|
70 | + if (!isset($connectParams['port'])) { |
|
71 | 71 | throw new \InvalidArgumentException('not set port'); |
72 | 72 | } |
73 | 73 | |
74 | - if (! isset($connectParams['host'])) { |
|
74 | + if (!isset($connectParams['host'])) { |
|
75 | 75 | throw new \InvalidArgumentException('not set host'); |
76 | 76 | } |
77 | 77 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | // apply settings to transport class |
94 | 94 | $this->settings()->database('default'); |
95 | - if (! empty($settings)) { |
|
95 | + if (!empty($settings)) { |
|
96 | 96 | $this->settings()->apply($settings); |
97 | 97 | } |
98 | 98 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function transport() |
200 | 200 | { |
201 | - if (! $this->transport) { |
|
201 | + if (!$this->transport) { |
|
202 | 202 | throw new \InvalidArgumentException('Empty transport class'); |
203 | 203 | } |
204 | 204 | |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | */ |
267 | 267 | public function useSession(bool $useSessionId = false) |
268 | 268 | { |
269 | - if (! $this->settings()->getSessionId()) { |
|
270 | - if (! $useSessionId) { |
|
269 | + if (!$this->settings()->getSessionId()) { |
|
270 | + if (!$useSessionId) { |
|
271 | 271 | $this->settings()->makeSessionId(); |
272 | 272 | } else { |
273 | 273 | $this->settings()->session_id($useSessionId); |
@@ -381,14 +381,14 @@ discard block |
||
381 | 381 | */ |
382 | 382 | public function progressFunction(callable $callback) |
383 | 383 | { |
384 | - if (! is_callable($callback)) { |
|
384 | + if (!is_callable($callback)) { |
|
385 | 385 | throw new \InvalidArgumentException('Not is_callable progressFunction'); |
386 | 386 | } |
387 | 387 | |
388 | - if (! $this->settings()->is('send_progress_in_http_headers')) { |
|
388 | + if (!$this->settings()->is('send_progress_in_http_headers')) { |
|
389 | 389 | $this->settings()->set('send_progress_in_http_headers', 1); |
390 | 390 | } |
391 | - if (! $this->settings()->is('http_headers_progress_interval_ms')) { |
|
391 | + if (!$this->settings()->is('http_headers_progress_interval_ms')) { |
|
392 | 392 | $this->settings()->set('http_headers_progress_interval_ms', 100); |
393 | 393 | } |
394 | 394 | |
@@ -567,14 +567,14 @@ discard block |
||
567 | 567 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
568 | 568 | } |
569 | 569 | |
570 | - if (! in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
570 | + if (!in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
571 | 571 | throw new QueryException('Format not support in insertBatchFiles'); |
572 | 572 | } |
573 | 573 | |
574 | 574 | $result = []; |
575 | 575 | |
576 | 576 | foreach ($fileNames as $fileName) { |
577 | - if (! is_file($fileName) || ! is_readable($fileName)) { |
|
577 | + if (!is_file($fileName) || !is_readable($fileName)) { |
|
578 | 578 | throw new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file')); |
579 | 579 | } |
580 | 580 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | |
592 | 592 | // fetch resutl |
593 | 593 | foreach ($fileNames as $fileName) { |
594 | - if (! $result[$fileName]->isError()) { |
|
594 | + if (!$result[$fileName]->isError()) { |
|
595 | 595 | continue; |
596 | 596 | } |
597 | 597 | |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
615 | 615 | } |
616 | 616 | |
617 | - if (! in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
617 | + if (!in_array($format, self::SUPPORTED_FORMATS, true)) { |
|
618 | 618 | throw new QueryException('Format not support in insertBatchFiles'); |
619 | 619 | } |
620 | 620 |