@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @var int |
85 | 85 | */ |
86 | - public $iterator=0; |
|
86 | + public $iterator = 0; |
|
87 | 87 | |
88 | 88 | |
89 | 89 | public function __construct(CurlerRequest $request) |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | $this->_init = true; |
222 | 222 | return false; |
223 | 223 | } |
224 | - $data=[]; |
|
224 | + $data = []; |
|
225 | 225 | foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least', 'statistics'] as $key) { |
226 | 226 | |
227 | 227 | if (isset($this->_rawData[$key])) { |
228 | - if ($key=='data') |
|
228 | + if ($key == 'data') |
|
229 | 229 | { |
230 | - $data=$this->_rawData[$key]; |
|
230 | + $data = $this->_rawData[$key]; |
|
231 | 231 | } |
232 | - else{ |
|
232 | + else { |
|
233 | 233 | $this->{$key} = $this->_rawData[$key]; |
234 | 234 | } |
235 | 235 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | throw new QueryException('Can`t find meta'); |
241 | 241 | } |
242 | 242 | |
243 | - $isJSONCompact=(stripos($this->format,'JSONCompact')!==false?true:false); |
|
243 | + $isJSONCompact = (stripos($this->format, 'JSONCompact') !== false ?true:false); |
|
244 | 244 | $this->array_data = []; |
245 | 245 | foreach ($data as $rows) { |
246 | 246 | $r = []; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | if ($isJSONCompact) |
250 | 250 | { |
251 | - $r[]=$rows; |
|
251 | + $r[] = $rows; |
|
252 | 252 | } |
253 | 253 | else { |
254 | 254 | foreach ($this->meta as $meta) { |
@@ -404,14 +404,14 @@ discard block |
||
404 | 404 | */ |
405 | 405 | public function resetIterator() |
406 | 406 | { |
407 | - $this->iterator=0; |
|
407 | + $this->iterator = 0; |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | public function fetchRow($key = null) |
411 | 411 | { |
412 | 412 | $this->init(); |
413 | 413 | |
414 | - $position=$this->iterator; |
|
414 | + $position = $this->iterator; |
|
415 | 415 | |
416 | 416 | if (!isset($this->array_data[$position])) { |
417 | 417 | return null; |
@@ -228,8 +228,7 @@ discard block |
||
228 | 228 | if ($key=='data') |
229 | 229 | { |
230 | 230 | $data=$this->_rawData[$key]; |
231 | - } |
|
232 | - else{ |
|
231 | + } else{ |
|
233 | 232 | $this->{$key} = $this->_rawData[$key]; |
234 | 233 | } |
235 | 234 | |
@@ -249,8 +248,7 @@ discard block |
||
249 | 248 | if ($isJSONCompact) |
250 | 249 | { |
251 | 250 | $r[]=$rows; |
252 | - } |
|
253 | - else { |
|
251 | + } else { |
|
254 | 252 | foreach ($this->meta as $meta) { |
255 | 253 | $r[$meta['name']] = $rows[$meta['name']]; |
256 | 254 | } |
@@ -364,7 +362,9 @@ discard block |
||
364 | 362 | return null; |
365 | 363 | } |
366 | 364 | |
367 | - if (!$key) return $this->statistics; |
|
365 | + if (!$key) { |
|
366 | + return $this->statistics; |
|
367 | + } |
|
368 | 368 | |
369 | 369 | if (!isset($this->statistics[$key])) { |
370 | 370 | return null; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function enableLogQueries(bool $flag = true) |
320 | 320 | { |
321 | - $this->settings()->set('log_queries', (int)$flag); |
|
321 | + $this->settings()->set('log_queries', (int) $flag); |
|
322 | 322 | |
323 | 323 | return $this; |
324 | 324 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function enableExtremes(bool $flag = true) |
356 | 356 | { |
357 | - $this->settings()->set('extremes', (int)$flag); |
|
357 | + $this->settings()->set('extremes', (int) $flag); |
|
358 | 358 | |
359 | 359 | return $this; |
360 | 360 | } |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | public function partitions(string $table, int $limit = null, bool $active = null) |
779 | 779 | { |
780 | 780 | $database = $this->settings()->getDatabase(); |
781 | - $whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int)$active); |
|
781 | + $whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int) $active); |
|
782 | 782 | $limitClause = $limit !== null ? ' LIMIT ' . $limit : ''; |
783 | 783 | |
784 | 784 | return $this->select(<<<CLICKHOUSE |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public function getServerVersion(): string |
844 | 844 | { |
845 | - return (string)$this->select('SELECT version() as version')->fetchOne('version'); |
|
845 | + return (string) $this->select('SELECT version() as version')->fetchOne('version'); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | $new->timeOut($this->settings()->getTimeOut()); |
224 | - $new->connectTimeOut($this->_connectTimeOut);//->keepAlive(); // one sec |
|
224 | + $new->connectTimeOut($this->_connectTimeOut); //->keepAlive(); // one sec |
|
225 | 225 | $new->verbose(boolval($this->_verbose)); |
226 | 226 | |
227 | 227 | return $new; |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | $request = $this->newRequest($extendinfo); |
318 | 318 | $request->url($url); |
319 | 319 | |
320 | - $request->setCallbackFunction(function (CurlerRequest $request) { |
|
320 | + $request->setCallbackFunction(function(CurlerRequest $request) { |
|
321 | 321 | $handle = $request->getInfileHandle(); |
322 | 322 | if (is_resource($handle)) { |
323 | 323 | fclose($handle); |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | } |
457 | 457 | |
458 | 458 | |
459 | - $request->setResultFileHandle($fout, $isGz)->setCallbackFunction(function (CurlerRequest $request) { |
|
459 | + $request->setResultFileHandle($fout, $isGz)->setCallbackFunction(function(CurlerRequest $request) { |
|
460 | 460 | fclose($request->getResultFileHandle()); |
461 | 461 | }); |
462 | 462 | } |
@@ -643,11 +643,11 @@ discard block |
||
643 | 643 | if (!is_callable($callable)) { |
644 | 644 | if ($streamRW->isWrite()) { |
645 | 645 | |
646 | - $callable = function ($ch, $fd, $length) use ($stream) { |
|
646 | + $callable = function($ch, $fd, $length) use ($stream) { |
|
647 | 647 | return ($line = fread($stream, $length)) ? $line : ''; |
648 | 648 | }; |
649 | 649 | } else { |
650 | - $callable = function ($ch, $fd) use ($stream) { |
|
650 | + $callable = function($ch, $fd) use ($stream) { |
|
651 | 651 | return fwrite($stream, $fd); |
652 | 652 | }; |
653 | 653 | } |
@@ -685,8 +685,9 @@ |
||
685 | 685 | } |
686 | 686 | return $response; |
687 | 687 | } finally { |
688 | - if ($streamRW->isWrite()) |
|
689 | - fclose($stream); |
|
688 | + if ($streamRW->isWrite()) { |
|
689 | + fclose($stream); |
|
690 | + } |
|
690 | 691 | } |
691 | 692 | |
692 | 693 |