Passed
Push — master ( 94ffb8...e27b04 )
by Igor
02:11
created
example/cluster/cluster_07_test_ddl.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 
8 8
 
9 9
 
10
-$cl = new ClickHouseDB\Cluster(['host'=>'172.18.0.8','username'=>'default','password'=>'','port'=>8123]);
10
+$cl = new ClickHouseDB\Cluster(['host'=>'172.18.0.8', 'username'=>'default', 'password'=>'', 'port'=>8123]);
11 11
 
12 12
 $cl->setScanTimeOut(2.5); // 2500 ms
13 13
 $cl->setSoftCheck(true);
14 14
 if (!$cl->isReplicasIsOk())
15 15
 {
16
-    throw new Exception('Replica state is bad , error='.$cl->getError());
16
+    throw new Exception('Replica state is bad , error=' . $cl->getError());
17 17
 }
18 18
 
19 19
 print_r($cl->getClusterList());
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 
26 26
 
27 27
 $cl->activeClient()->setTimeout(0.01);
28
-for ($z=0;$z<50;$z++)
28
+for ($z = 0; $z < 50; $z++)
29 29
 {
30
-    try{
31
-        $x=$cl->activeClient()->write("DROP TABLE IF EXISTS default.asdasdasd ON CLUSTER cluster2");
30
+    try {
31
+        $x = $cl->activeClient()->write("DROP TABLE IF EXISTS default.asdasdasd ON CLUSTER cluster2");
32 32
     }catch (Exception $exception)
33 33
     {
34 34
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 }
37 37
 
38 38
 $cl->activeClient()->setTimeout(22);
39
-$x=$cl->activeClient()->write("DROP TABLE IF EXISTS default.asdasdasd ON CLUSTER cluster2");
39
+$x = $cl->activeClient()->write("DROP TABLE IF EXISTS default.asdasdasd ON CLUSTER cluster2");
40 40
 $x->dump();
41 41
 
42 42
 
Please login to merge, or discard this patch.
example/cluster/cluster_05_select_node.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 $cl->setSoftCheck(true);
13 13
 if (!$cl->isReplicasIsOk())
14 14
 {
15
-    throw new Exception('Replica state is bad , error='.$cl->getError());
15
+    throw new Exception('Replica state is bad , error=' . $cl->getError());
16 16
 }
17 17
 //
18
-$cluster_name='sharovara';
18
+$cluster_name = 'sharovara';
19 19
 //
20
-echo "> $cluster_name , count shard   = ".$cl->getClusterCountShard($cluster_name)." ; count replica = ".$cl->getClusterCountReplica($cluster_name)."\n";
20
+echo "> $cluster_name , count shard   = " . $cl->getClusterCountShard($cluster_name) . " ; count replica = " . $cl->getClusterCountReplica($cluster_name) . "\n";
21 21
 
22 22
 
23 23
 // Выбрать IP содержащий строку ".248" типа 123.123.123.248, разделитель ; - если не найдена первая берется
24
-$cli=$cl->clientLike($cluster_name,'.298;.964');
24
+$cli = $cl->clientLike($cluster_name, '.298;.964');
25 25
 $cli->ping();
26 26
 echo "\n----\nEND\n";
27 27
 // ----------------------------------------------------------------------
Please login to merge, or discard this patch.
example/cluster/cluster_01_start.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $cl->setScanTimeOut(2.5); // 2500 ms
11 11
 if (!$cl->isReplicasIsOk())
12 12
 {
13
-    throw new Exception('Replica state is bad , error='.$cl->getError());
13
+    throw new Exception('Replica state is bad , error=' . $cl->getError());
14 14
 }
15 15
 
16 16
 echo "Ips:\n";
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 print_r($cl->getClusterList());
20 20
 
21 21
 //
22
-foreach (['pulse','repikator','sharovara','repikator3x','sharovara3x'] as $name)
22
+foreach (['pulse', 'repikator', 'sharovara', 'repikator3x', 'sharovara3x'] as $name)
23 23
 {
24 24
     echo "-------------------- $name ---------------------------\n";
25 25
     print_r($cl->getClusterNodes($name));
26 26
 
27
-    echo "> Count Shard   = ".$cl->getClusterCountShard($name)."\n";
28
-    echo "> Count Replica = ".$cl->getClusterCountReplica($name)."\n";
27
+    echo "> Count Shard   = " . $cl->getClusterCountShard($name) . "\n";
28
+    echo "> Count Replica = " . $cl->getClusterCountReplica($name) . "\n";
29 29
 }
30 30
 // ----------------------------------------------------------------------
31 31
 echo "\n----\nEND\n";
Please login to merge, or discard this patch.
example/exam12_array.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 
53 53
 echo "\ntestRFCCSVWrite>>>>\n";
54
-$fileName='/tmp/testRFCCSVWrite.CSV';
54
+$fileName = '/tmp/testRFCCSVWrite.CSV';
55 55
 date_default_timezone_set('Europe/Moscow');
56 56
 $db->write("DROP TABLE IF EXISTS testRFCCSVWrite");
57 57
 $db->write('CREATE TABLE testRFCCSVWrite (
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
 
67 67
 @unlink($fileName);
68 68
 
69
-$data=[
70
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>'SOME STRING','flos'=>1.1,'ints'=>1,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
71
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>'SOME STRING','flos'=>2.3,'ints'=>2,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
72
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>'SOME\'STRING','flos'=>0,'ints'=>0,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
73
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>'SOME\'"TRING','flos'=>0,'ints'=>0,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
74
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>"SOMET\nRI\n\"N\"G\\XX_ABCDEFG",'flos'=>0,'ints'=>0,'arr1'=>[1,2,3],'arrs'=>["A","B\nD\nC"]],
75
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>"ID_ARRAY",'flos'=>0,'ints'=>0,'arr1'=>[1,2,3],'arrs'=>["A","B\nD\nC"]]
69
+$data = [
70
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>'SOME STRING', 'flos'=>1.1, 'ints'=>1, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
71
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>'SOME STRING', 'flos'=>2.3, 'ints'=>2, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
72
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>'SOME\'STRING', 'flos'=>0, 'ints'=>0, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
73
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>'SOME\'"TRING', 'flos'=>0, 'ints'=>0, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
74
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>"SOMET\nRI\n\"N\"G\\XX_ABCDEFG", 'flos'=>0, 'ints'=>0, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B\nD\nC"]],
75
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>"ID_ARRAY", 'flos'=>0, 'ints'=>0, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B\nD\nC"]]
76 76
 ];
77 77
 
78 78
 //// 1.1 + 2.3 = 3.3999999761581
79 79
 //
80 80
 foreach ($data as $row)
81 81
 {
82
-    file_put_contents($fileName,\ClickHouseDB\Quote\FormatLine::CSV($row)."\n",FILE_APPEND);
82
+    file_put_contents($fileName, \ClickHouseDB\Quote\FormatLine::CSV($row) . "\n", FILE_APPEND);
83 83
 }
84 84
 //
85 85
 echo "FILE:\n\n";
86
-echo file_get_contents($fileName)."\n\n----\n";
86
+echo file_get_contents($fileName) . "\n\n----\n";
87 87
 
88 88
 //
89 89
 $db->insertBatchFiles('testRFCCSVWrite', [$fileName], [
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
     'arrs',
96 96
 ]);
97 97
 
98
-$st=$db->select('SELECT * FROM testRFCCSVWrite');
98
+$st = $db->select('SELECT * FROM testRFCCSVWrite');
99 99
 print_r($st->rows());
100 100
 //
101 101
 
102 102
 
103 103
 echo "\n<<<<< TAB >>>>\n";
104
-$fileName='/tmp/testRFCCSVWrite.TAB';@unlink($fileName);
104
+$fileName = '/tmp/testRFCCSVWrite.TAB'; @unlink($fileName);
105 105
 
106 106
 
107 107
 $db->write("DROP TABLE IF EXISTS testTABWrite");
@@ -117,22 +117,22 @@  discard block
 block discarded – undo
117 117
 
118 118
 
119 119
 
120
-$data=[
121
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>"STING\t\tSD!\"\nFCD\tSAD\t\nDSF",'flos'=>-2.3,'ints'=>123,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
122
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>'SOME\'STRING','flos'=>0,'ints'=>12123,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
123
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>'SOME\'"TR\tING','flos'=>0,'ints'=>0,'arr1'=>[1,2,3],'arrs'=>["A","B"]],
124
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>"SOMET\nRI\n\"N\"G\\XX_ABCDEFG",'flos'=>0,'ints'=>1,'arr1'=>[1,2,3],'arrs'=>["A","B\nD\ns\tC"]],
125
-    ['event_time'=>date('Y-m-d H:i:s'),'strs'=>"ID_ARRAY",'flos'=>-2.3,'ints'=>-12123,'arr1'=>[1,2,3],'arrs'=>["A","B\nD\nC\n\t\n\tTABARRAYS"]]
120
+$data = [
121
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>"STING\t\tSD!\"\nFCD\tSAD\t\nDSF", 'flos'=>-2.3, 'ints'=>123, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
122
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>'SOME\'STRING', 'flos'=>0, 'ints'=>12123, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
123
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>'SOME\'"TR\tING', 'flos'=>0, 'ints'=>0, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B"]],
124
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>"SOMET\nRI\n\"N\"G\\XX_ABCDEFG", 'flos'=>0, 'ints'=>1, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B\nD\ns\tC"]],
125
+    ['event_time'=>date('Y-m-d H:i:s'), 'strs'=>"ID_ARRAY", 'flos'=>-2.3, 'ints'=>-12123, 'arr1'=>[1, 2, 3], 'arrs'=>["A", "B\nD\nC\n\t\n\tTABARRAYS"]]
126 126
 ];
127 127
 
128 128
 
129 129
 foreach ($data as $row)
130 130
 {
131
-    file_put_contents($fileName,\ClickHouseDB\Quote\FormatLine::TSV($row)."\n",FILE_APPEND);
131
+    file_put_contents($fileName, \ClickHouseDB\Quote\FormatLine::TSV($row) . "\n", FILE_APPEND);
132 132
 }
133 133
 //
134 134
 echo "FILE:\n\n";
135
-echo file_get_contents($fileName)."\n\n----\n";
135
+echo file_get_contents($fileName) . "\n\n----\n";
136 136
 
137 137
 //
138 138
 $db->insertBatchTSVFiles('testTABWrite', [$fileName], [
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
     'arrs',
145 145
 ]);
146 146
 
147
-$st=$db->select('SELECT * FROM testTABWrite');
147
+$st = $db->select('SELECT * FROM testTABWrite');
148 148
 print_r($st->rows());
149
-$st=$db->select('SELECT round(sum(flos),5),sum(ints) FROM testTABWrite');
149
+$st = $db->select('SELECT round(sum(flos),5),sum(ints) FROM testTABWrite');
150 150
 print_r($st->rows());
151 151
 
152 152
 //
153 153
\ No newline at end of file
Please login to merge, or discard this patch.
example/exam14_Statistics_in_JSON.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@
 block discarded – undo
24 24
 
25 25
 
26 26
 
27
-echo 'elapsed   :'.$result->statistics('elapsed')."\n";
28
-echo 'rows_read :'.$result->statistics('rows_read')."\n";
29
-echo 'bytes_read:'.$result->statistics('bytes_read')."\n";
27
+echo 'elapsed   :' . $result->statistics('elapsed') . "\n";
28
+echo 'rows_read :' . $result->statistics('rows_read') . "\n";
29
+echo 'bytes_read:' . $result->statistics('bytes_read') . "\n";
30 30
 
31 31
 //
32 32
 $result = $db->select("SELECT 12 as ping");
Please login to merge, or discard this patch.
src/Statement.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
         $body = $this->response()->body();
150 150
         $error_no = $this->response()->error_no();
151
-        $error=$this->response()->error();
151
+        $error = $this->response()->error();
152 152
 
153 153
         if (!$error_no && !$error) {
154 154
             $parse = $this->parseErrorClickHouse($body);
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             }
159 159
             else {
160 160
                 $code = $this->response()->http_code();
161
-                $message = "HttpCode:" . $this->response()->http_code() . " ; ".$this->response()->error()." ;" . $body;
161
+                $message = "HttpCode:" . $this->response()->http_code() . " ; " . $this->response()->error() . " ;" . $body;
162 162
             }
163 163
         }
164 164
         else {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
             return false;
213 213
         }
214 214
 
215
-        foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least','statistics'] as $key) {
215
+        foreach (['meta', 'data', 'totals', 'extremes', 'rows', 'rows_before_limit_at_least', 'statistics'] as $key) {
216 216
             if (isset($this->_rawData[$key])) {
217 217
                 $this->{$key} = $this->_rawData[$key];
218 218
             }
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
      * @param bool $key
326 326
      * @return array|mixed|null
327 327
      */
328
-    public function statistics($key=false)
328
+    public function statistics($key = false)
329 329
     {
330 330
         $this->init();
331 331
         if ($key)
Please login to merge, or discard this patch.
src/Quote/StrictQuoteLine.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 class StrictQuoteLine
7 7
 {
8 8
 
9
-    private $preset=[
9
+    private $preset = [
10 10
         'CSV'=>[
11 11
             'EnclosureArray'=>'"',
12 12
             'EncodeEnclosure'=>'"',
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
             'TabEncode'=>true,
33 33
         ],
34 34
     ];
35
-    private $settings=[];
35
+    private $settings = [];
36 36
 
37 37
     public function __construct($format)
38 38
     {
39 39
         if (empty($this->preset[$format]))
40 40
         {
41
-            throw new QueryException("Unsupport format encode line:".$format);
41
+            throw new QueryException("Unsupport format encode line:" . $format);
42 42
         }
43
-        $this->settings=$this->preset[$format];
43
+        $this->settings = $this->preset[$format];
44 44
     }
45 45
     public function quoteRow($row)
46 46
     {
47
-        return implode($this->settings['Delimiter'],$this->quoteValue($row));
47
+        return implode($this->settings['Delimiter'], $this->quoteValue($row));
48 48
     }
49 49
     public function quoteValue($row)
50 50
     {
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
         $encode = $this->settings['EncodeEnclosure'];
54 54
         $encodeArray = $this->settings['EnclosureArray'];
55 55
         $null = $this->settings['Null'];
56
-        $tabEncode=$this->settings['TabEncode'];
56
+        $tabEncode = $this->settings['TabEncode'];
57 57
 
58 58
 
59
-        $quote = function ($value) use ($enclosure,$delimiter,$encode,$encodeArray,$null,$tabEncode) {
59
+        $quote = function($value) use ($enclosure, $delimiter, $encode, $encodeArray, $null, $tabEncode) {
60 60
 
61 61
 
62 62
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
             if (is_string($value)) {
76 76
                 if ($tabEncode)
77 77
                 {
78
-                    return str_replace(["\t","\n"],['\\t','\\n'],$value);
78
+                    return str_replace(["\t", "\n"], ['\\t', '\\n'], $value);
79 79
                 }
80 80
 
81 81
                 $value = strval($value);
82
-                $value = preg_replace('/('.$enclosure_esc.'|'.$encode_esc.')/',$encode_esc.'\1', $value);
82
+                $value = preg_replace('/(' . $enclosure_esc . '|' . $encode_esc . ')/', $encode_esc . '\1', $value);
83 83
                 return $enclosure . $value . $enclosure;
84 84
             }
85 85
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 // as in the TabSeparated format, and then the resulting string is output in InsertRow in double quotes.
91 91
                 $result_array = FormatLine::Insert($value);
92 92
 
93
-                return $encodeArray . '[' . $result_array . ']' .$encodeArray;
93
+                return $encodeArray . '[' . $result_array . ']' . $encodeArray;
94 94
             }
95 95
 
96 96
             if (null === $value) {
Please login to merge, or discard this patch.
src/Quote/FormatLine.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
      *
9 9
      * @var array
10 10
      */
11
-    private static $strict=[];
11
+    private static $strict = [];
12 12
 
13 13
     /**
14 14
      * Format
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     {
21 21
         if (empty(self::$strict[$format]))
22 22
         {
23
-            self::$strict[$format]=new StrictQuoteLine($format);
23
+            self::$strict[$format] = new StrictQuoteLine($format);
24 24
         }
25 25
         return self::$strict[$format];
26 26
     }
Please login to merge, or discard this patch.
src/Query/Degeneration/Bindings.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function bindParams(array $bindings)
15 15
     {
16
-        $this->bindings=[];
16
+        $this->bindings = [];
17 17
         foreach ($bindings as $column => $value) {
18 18
             $this->bindParam($column, $value);
19 19
         }
Please login to merge, or discard this patch.