@@ -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 |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function setWriteFunction($callback) |
243 | 243 | { |
244 | - $this->options[CURLOPT_WRITEFUNCTION]=$callback; |
|
244 | + $this->options[CURLOPT_WRITEFUNCTION] = $callback; |
|
245 | 245 | } |
246 | 246 | /** |
247 | 247 | * @param callable $callback |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | |
716 | 716 | if (!empty($curl_opt[CURLOPT_WRITEFUNCTION])) |
717 | 717 | { |
718 | - $curl_opt[CURLOPT_HEADER]=false; |
|
718 | + $curl_opt[CURLOPT_HEADER] = false; |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | if ($this->resultFileHandle) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | { |
241 | 241 | |
242 | 242 | if ($sql instanceof Query) { |
243 | - $query=$sql; |
|
243 | + $query = $sql; |
|
244 | 244 | } else { |
245 | 245 | $query = new Query($sql); |
246 | 246 | } |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | * @return Statement |
591 | 591 | * @throws \ClickHouseDB\Exception\TransportException |
592 | 592 | */ |
593 | - private function streaming(Stream $streamRW,CurlerRequest $request) |
|
593 | + private function streaming(Stream $streamRW, CurlerRequest $request) |
|
594 | 594 | { |
595 | - $callable=$streamRW->getClosure(); |
|
596 | - $stream=$streamRW->getStream(); |
|
595 | + $callable = $streamRW->getClosure(); |
|
596 | + $stream = $streamRW->getStream(); |
|
597 | 597 | |
598 | 598 | |
599 | 599 | |
@@ -604,11 +604,11 @@ discard block |
||
604 | 604 | if ($streamRW->isWrite()) |
605 | 605 | { |
606 | 606 | |
607 | - $callable = function ($ch, $fd, $length) use ($stream) { |
|
607 | + $callable = function($ch, $fd, $length) use ($stream) { |
|
608 | 608 | return ($line = fread($stream, $length)) ? $line : ''; |
609 | 609 | }; |
610 | 610 | } else { |
611 | - $callable = function ($ch, $fd) use ($stream) { |
|
611 | + $callable = function($ch, $fd) use ($stream) { |
|
612 | 612 | return fwrite($stream, $fd); |
613 | 613 | }; |
614 | 614 | } |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | } |
644 | 644 | |
645 | 645 | |
646 | - $this->_curler->execOne($request,true); |
|
646 | + $this->_curler->execOne($request, true); |
|
647 | 647 | $response = new Statement($request); |
648 | 648 | if ($response->isError()) { |
649 | 649 | $response->error(); |
@@ -665,11 +665,11 @@ discard block |
||
665 | 665 | * @return Statement |
666 | 666 | * @throws \ClickHouseDB\Exception\TransportException |
667 | 667 | */ |
668 | - public function streamRead(Stream $streamRead,$sql,$bindings=[]) |
|
668 | + public function streamRead(Stream $streamRead, $sql, $bindings = []) |
|
669 | 669 | { |
670 | - $sql=$this->prepareQuery($sql,$bindings); |
|
671 | - $request=$this->getRequestRead($sql); |
|
672 | - return $this->streaming($streamRead,$request); |
|
670 | + $sql = $this->prepareQuery($sql, $bindings); |
|
671 | + $request = $this->getRequestRead($sql); |
|
672 | + return $this->streaming($streamRead, $request); |
|
673 | 673 | |
674 | 674 | } |
675 | 675 | |
@@ -680,10 +680,10 @@ discard block |
||
680 | 680 | * @return Statement |
681 | 681 | * @throws \ClickHouseDB\Exception\TransportException |
682 | 682 | */ |
683 | - public function streamWrite(Stream $streamWrite,$sql,$bindings=[]) |
|
683 | + public function streamWrite(Stream $streamWrite, $sql, $bindings = []) |
|
684 | 684 | { |
685 | - $sql=$this->prepareQuery($sql,$bindings); |
|
685 | + $sql = $this->prepareQuery($sql, $bindings); |
|
686 | 686 | $request = $this->writeStreamData($sql); |
687 | - return $this->streaming($streamWrite,$request); |
|
687 | + return $this->streaming($streamWrite, $request); |
|
688 | 688 | } |
689 | 689 | } |
@@ -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 |
@@ -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 | } |
@@ -92,7 +92,7 @@ |
||
92 | 92 | return preg_replace_callback($pattern, function($m) use ($binds){ |
93 | 93 | if(isset($binds[$m[1]])){ // If it exists in our array |
94 | 94 | return $binds[$m[1]]; // Then replace it from our array |
95 | - }else{ |
|
95 | + } else{ |
|
96 | 96 | return $m[0]; // Otherwise return the whole match (basically we won't change it) |
97 | 97 | } |
98 | 98 | }, $sql); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * @param string $pattern |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function compile_binds($sql, $binds,$pattern) |
|
90 | + public function compile_binds($sql, $binds, $pattern) |
|
91 | 91 | { |
92 | 92 | return preg_replace_callback($pattern, function($m) use ($binds){ |
93 | - if(isset($binds[$m[1]])){ // If it exists in our array |
|
93 | + if (isset($binds[$m[1]])) { // If it exists in our array |
|
94 | 94 | return $binds[$m[1]]; // Then replace it from our array |
95 | - }else{ |
|
95 | + } else { |
|
96 | 96 | return $m[0]; // Otherwise return the whole match (basically we won't change it) |
97 | 97 | } |
98 | 98 | }, $sql); |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | { |
110 | 110 | arsort($this->bindings); |
111 | 111 | |
112 | - $bindFormatted=[]; |
|
113 | - $bindRaw=[]; |
|
112 | + $bindFormatted = []; |
|
113 | + $bindRaw = []; |
|
114 | 114 | foreach ($this->bindings as $key => $value) { |
115 | 115 | $valueSet = null; |
116 | 116 | $formattedParameter = null; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $escapedValues = $this->escapeArray($value); |
124 | 124 | |
125 | 125 | $escapedValues = array_map( |
126 | - function ($escapedValue) { |
|
126 | + function($escapedValue) { |
|
127 | 127 | if (is_string($escapedValue)) { |
128 | 128 | return $this->formatStringParameter($escapedValue); |
129 | 129 | } |
@@ -148,21 +148,21 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | if ($formattedParameter !== null) { |
151 | - $bindFormatted[$key]=$formattedParameter; |
|
151 | + $bindFormatted[$key] = $formattedParameter; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | if ($valueSet !== null) { |
155 | - $bindRaw[$key]=$valueSet; |
|
155 | + $bindRaw[$key] = $valueSet; |
|
156 | 156 | } |
157 | 157 | } |
158 | 158 | |
159 | - for ($loop=0;$loop<2;$loop++) |
|
159 | + for ($loop = 0; $loop < 2; $loop++) |
|
160 | 160 | { |
161 | 161 | // dipping in binds |
162 | 162 | // example ['A' => '{B}' , 'B'=>':C','C'=>123] |
163 | - $sql=$this->compile_binds($sql,$bindRaw,'#{([\w+]+)}#'); |
|
163 | + $sql = $this->compile_binds($sql, $bindRaw, '#{([\w+]+)}#'); |
|
164 | 164 | } |
165 | - $sql=$this->compile_binds($sql,$bindFormatted,'#:([\w+]+)#'); |
|
165 | + $sql = $this->compile_binds($sql, $bindFormatted, '#:([\w+]+)#'); |
|
166 | 166 | |
167 | 167 | return $sql; |
168 | 168 | } |