@@ -75,7 +75,7 @@ |
||
75 | 75 | $markers = $this->bindings; |
76 | 76 | |
77 | 77 | // ------ if/else conditions & if[set|int]/else conditions ----- |
78 | - $sql = preg_replace_callback('#\{if(.{0,}?)\s+([^\}]+?)\}(.+?)(\{else\}([^\{]+?)?)?\s*\{\/if}#sui', function ($matches) use ($markers) { |
|
78 | + $sql = preg_replace_callback('#\{if(.{0,}?)\s+([^\}]+?)\}(.+?)(\{else\}([^\{]+?)?)?\s*\{\/if}#sui', function($matches) use ($markers) { |
|
79 | 79 | return self::__ifsets($matches, $markers); |
80 | 80 | } |
81 | 81 | , $sql); |
@@ -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; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * @param CurlerRolling $curler |
94 | 94 | */ |
95 | - public function setDirtyCurler(CurlerRolling $curler){ |
|
96 | - if ($curler instanceof CurlerRolling){ |
|
95 | + public function setDirtyCurler(CurlerRolling $curler) { |
|
96 | + if ($curler instanceof CurlerRolling) { |
|
97 | 97 | $this->_curler = $curler; |
98 | 98 | } |
99 | 99 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | $proto = 'https'; |
130 | 130 | } |
131 | 131 | $uri = $proto . '://' . $this->_host; |
132 | - if (stripos($this->_host,'/')!==false || stripos($this->_host,':')!==false) { |
|
132 | + if (stripos($this->_host, '/') !== false || stripos($this->_host, ':') !== false) { |
|
133 | 133 | return $uri; |
134 | 134 | } |
135 | - if (intval($this->_port)>0) { |
|
135 | + if (intval($this->_port) > 0) { |
|
136 | 136 | return $uri . ':' . $this->_port; |
137 | 137 | } |
138 | 138 | return $uri; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | $new->timeOut($this->settings()->getTimeOut()); |
207 | - $new->connectTimeOut($this->_connectTimeOut);//->keepAlive(); // one sec |
|
207 | + $new->connectTimeOut($this->_connectTimeOut); //->keepAlive(); // one sec |
|
208 | 208 | $new->verbose(boolval($this->_verbose)); |
209 | 209 | |
210 | 210 | return $new; |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | { |
258 | 258 | |
259 | 259 | if ($sql instanceof Query) { |
260 | - $query=$sql; |
|
260 | + $query = $sql; |
|
261 | 261 | } else { |
262 | 262 | $query = new Query($sql); |
263 | 263 | } |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | * @return Statement |
620 | 620 | * @throws \ClickHouseDB\Exception\TransportException |
621 | 621 | */ |
622 | - private function streaming(Stream $streamRW,CurlerRequest $request) |
|
622 | + private function streaming(Stream $streamRW, CurlerRequest $request) |
|
623 | 623 | { |
624 | - $callable=$streamRW->getClosure(); |
|
625 | - $stream=$streamRW->getStream(); |
|
624 | + $callable = $streamRW->getClosure(); |
|
625 | + $stream = $streamRW->getStream(); |
|
626 | 626 | |
627 | 627 | |
628 | 628 | |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | if ($streamRW->isWrite()) |
634 | 634 | { |
635 | 635 | |
636 | - $callable = function ($ch, $fd, $length) use ($stream) { |
|
636 | + $callable = function($ch, $fd, $length) use ($stream) { |
|
637 | 637 | return ($line = fread($stream, $length)) ? $line : ''; |
638 | 638 | }; |
639 | 639 | } else { |
640 | - $callable = function ($ch, $fd) use ($stream) { |
|
640 | + $callable = function($ch, $fd) use ($stream) { |
|
641 | 641 | return fwrite($stream, $fd); |
642 | 642 | }; |
643 | 643 | } |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | } |
673 | 673 | |
674 | 674 | |
675 | - $this->_curler->execOne($request,true); |
|
675 | + $this->_curler->execOne($request, true); |
|
676 | 676 | $response = new Statement($request); |
677 | 677 | if ($response->isError()) { |
678 | 678 | $response->error(); |
@@ -694,11 +694,11 @@ discard block |
||
694 | 694 | * @return Statement |
695 | 695 | * @throws \ClickHouseDB\Exception\TransportException |
696 | 696 | */ |
697 | - public function streamRead(Stream $streamRead,$sql,$bindings=[]) |
|
697 | + public function streamRead(Stream $streamRead, $sql, $bindings = []) |
|
698 | 698 | { |
699 | - $sql=$this->prepareQuery($sql,$bindings); |
|
700 | - $request=$this->getRequestRead($sql); |
|
701 | - return $this->streaming($streamRead,$request); |
|
699 | + $sql = $this->prepareQuery($sql, $bindings); |
|
700 | + $request = $this->getRequestRead($sql); |
|
701 | + return $this->streaming($streamRead, $request); |
|
702 | 702 | |
703 | 703 | } |
704 | 704 | |
@@ -709,10 +709,10 @@ discard block |
||
709 | 709 | * @return Statement |
710 | 710 | * @throws \ClickHouseDB\Exception\TransportException |
711 | 711 | */ |
712 | - public function streamWrite(Stream $streamWrite,$sql,$bindings=[]) |
|
712 | + public function streamWrite(Stream $streamWrite, $sql, $bindings = []) |
|
713 | 713 | { |
714 | - $sql=$this->prepareQuery($sql,$bindings); |
|
714 | + $sql = $this->prepareQuery($sql, $bindings); |
|
715 | 715 | $request = $this->writeStreamData($sql); |
716 | - return $this->streaming($streamWrite,$request); |
|
716 | + return $this->streaming($streamWrite, $request); |
|
717 | 717 | } |
718 | 718 | } |