@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * @return mixed |
| 590 | 590 | * @throws Exception\TransportException |
| 591 | 591 | */ |
| 592 | - public function insertBatchTSVFiles($table_name, $file_names, $columns_array=[]) |
|
| 592 | + public function insertBatchTSVFiles($table_name, $file_names, $columns_array = []) |
|
| 593 | 593 | { |
| 594 | 594 | return $this->insertBatchFiles($table_name, $file_names, $columns_array, 'TabSeparated'); |
| 595 | 595 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @return array |
| 605 | 605 | * @throws Exception\TransportException |
| 606 | 606 | */ |
| 607 | - public function insertBatchFiles($table_name, $file_names, $columns_array=[], $format = "CSV") |
|
| 607 | + public function insertBatchFiles($table_name, $file_names, $columns_array = [], $format = "CSV") |
|
| 608 | 608 | { |
| 609 | 609 | if (is_string($file_names)) |
| 610 | 610 | { |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | * @param string $format ['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames'] |
| 660 | 660 | * @return Transport\CurlerRequest |
| 661 | 661 | */ |
| 662 | - public function insertBatchStream($table_name, $columns_array=[], $format = "CSV") |
|
| 662 | + public function insertBatchStream($table_name, $columns_array = [], $format = "CSV") |
|
| 663 | 663 | { |
| 664 | 664 | if ($this->getCountPendingQueue() > 0) { |
| 665 | 665 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
@@ -693,12 +693,12 @@ discard block |
||
| 693 | 693 | * @return Statement |
| 694 | 694 | * @throws Exception\TransportException |
| 695 | 695 | */ |
| 696 | - public function streamWrite(Stream $stream,$sql,$bind=[]) |
|
| 696 | + public function streamWrite(Stream $stream, $sql, $bind = []) |
|
| 697 | 697 | { |
| 698 | 698 | if ($this->getCountPendingQueue() > 0) { |
| 699 | 699 | throw new QueryException('Queue must be empty, before streamWrite'); |
| 700 | 700 | } |
| 701 | - return $this->transport()->streamWrite($stream,$sql,$bind); |
|
| 701 | + return $this->transport()->streamWrite($stream, $sql, $bind); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | * @return Statement |
| 712 | 712 | * @throws Exception\TransportException |
| 713 | 713 | */ |
| 714 | - public function streamRead(Stream $streamRead,$sql,$bind=[]) |
|
| 714 | + public function streamRead(Stream $streamRead, $sql, $bind = []) |
|
| 715 | 715 | { |
| 716 | 716 | if ($this->getCountPendingQueue() > 0) { |
| 717 | 717 | throw new QueryException('Queue must be empty, before streamWrite'); |
| 718 | 718 | } |
| 719 | - return $this->transport()->streamRead($streamRead,$sql,$bind); |
|
| 719 | + return $this->transport()->streamRead($streamRead, $sql, $bind); |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /** |
@@ -910,12 +910,12 @@ discard block |
||
| 910 | 910 | * @return array |
| 911 | 911 | * @throws Exception\TransportException |
| 912 | 912 | */ |
| 913 | - public function getServerSystemSettings($like='') |
|
| 913 | + public function getServerSystemSettings($like = '') |
|
| 914 | 914 | { |
| 915 | - $l=[]; |
|
| 916 | - $list=$this->select('SELECT * FROM system.settings'.($like ? ' WHERE name LIKE :like':'' ),['like'=>'%'.$like.'%'])->rows(); |
|
| 915 | + $l = []; |
|
| 916 | + $list = $this->select('SELECT * FROM system.settings' . ($like ? ' WHERE name LIKE :like' : ''), ['like'=>'%' . $like . '%'])->rows(); |
|
| 917 | 917 | foreach ($list as $row) { |
| 918 | - if (isset($row['name'])) {$n=$row['name']; unset($row['name']) ; $l[$n]=$row;} |
|
| 918 | + if (isset($row['name'])) {$n = $row['name']; unset($row['name']); $l[$n] = $row; } |
|
| 919 | 919 | } |
| 920 | 920 | return $l; |
| 921 | 921 | } |
@@ -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(); |
@@ -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) { |
@@ -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) { |
@@ -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) { |
@@ -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 | } |