@@ -16,12 +16,12 @@ discard block |
||
16 | 16 | */ |
17 | 17 | private $settings = []; |
18 | 18 | |
19 | - private $_ReadOnlyUser=false; |
|
19 | + private $_ReadOnlyUser = false; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @var bool |
23 | 23 | */ |
24 | - private $_isHttps=false; |
|
24 | + private $_isHttps = false; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Settings constructor. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | |
119 | - public function https($flag=true) |
|
119 | + public function https($flag = true) |
|
120 | 120 | { |
121 | 121 | $this->set('https', $flag); |
122 | 122 | return $this; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function setReadOnlyUser($flag) |
203 | 203 | { |
204 | - $this->_ReadOnlyUser=$flag; |
|
204 | + $this->_ReadOnlyUser = $flag; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -152,7 +152,9 @@ |
||
152 | 152 | */ |
153 | 153 | public function getSessionId() |
154 | 154 | { |
155 | - if (empty($this->settings['session_id'])) return false; |
|
155 | + if (empty($this->settings['session_id'])) { |
|
156 | + return false; |
|
157 | + } |
|
156 | 158 | return $this->get('session_id'); |
157 | 159 | } |
158 | 160 |
@@ -13,27 +13,27 @@ |
||
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 | |
20 | -$tables=$cl->getTables(); |
|
20 | +$tables = $cl->getTables(); |
|
21 | 21 | |
22 | 22 | foreach ($tables as $dbtable=>$tmp) |
23 | 23 | { |
24 | 24 | echo ">>> $dbtable :"; |
25 | 25 | |
26 | - $size=$cl->getSizeTable($dbtable); |
|
26 | + $size = $cl->getSizeTable($dbtable); |
|
27 | 27 | |
28 | 28 | |
29 | - echo "\t".\ClickHouseDB\Example\Helper::humanFileSize($size)."\n"; |
|
29 | + echo "\t" . \ClickHouseDB\Example\Helper::humanFileSize($size) . "\n"; |
|
30 | 30 | |
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | -$table_for_truncate='target.events_sharded'; |
|
34 | +$table_for_truncate = 'target.events_sharded'; |
|
35 | 35 | |
36 | -$result=$cl->truncateTable($table_for_truncate); |
|
36 | +$result = $cl->truncateTable($table_for_truncate); |
|
37 | 37 | |
38 | 38 | echo "Result:truncate table\n"; |
39 | 39 | print_r($result); |
@@ -12,10 +12,10 @@ |
||
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
15 | - * @param $file_name |
|
16 | - * @param int $from_id |
|
17 | - * @param int $to_id |
|
18 | - */ |
|
15 | + * @param $file_name |
|
16 | + * @param int $from_id |
|
17 | + * @param int $to_id |
|
18 | + */ |
|
19 | 19 | public static function makeListSitesKeysDataFile($file_name, $from_id = 1000, $to_id = 20000) |
20 | 20 | { |
21 | 21 | @unlink($file_name); |
@@ -7,8 +7,8 @@ |
||
7 | 7 | public static function init() |
8 | 8 | { |
9 | 9 | date_default_timezone_set('Europe/Moscow'); |
10 | - error_reporting( E_ALL ); |
|
11 | - ini_set('display_errors',1); |
|
10 | + error_reporting(E_ALL); |
|
11 | + ini_set('display_errors', 1); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -123,8 +123,10 @@ |
||
123 | 123 | |
124 | 124 | for ($day_ago = 0; $day_ago < 360; $day_ago++) { |
125 | 125 | $date = strtotime('-' . $day_ago . ' day'); |
126 | - for ($hash_id = 1; $hash_id < (1 + $size); $hash_id++) |
|
127 | - for ($site_id = 100; $site_id < 199; $site_id++) { |
|
126 | + for ($hash_id = 1; $hash_id < (1 + $size); $hash_id++) { |
|
127 | + for ($site_id = 100; |
|
128 | + } |
|
129 | + $site_id < 199; $site_id++) { |
|
128 | 130 | $j['event_time'] = date('Y-m-d H:00:00', $date); |
129 | 131 | $j['site_id'] = $site_id; |
130 | 132 | $j['hash_id'] = $hash_id; |
@@ -49,7 +49,9 @@ discard block |
||
49 | 49 | private function applyFormatQuery() |
50 | 50 | { |
51 | 51 | // FORMAT\s(\w)*$ |
52 | - if (null === $this->format) return false; |
|
52 | + if (null === $this->format) { |
|
53 | + return false; |
|
54 | + } |
|
53 | 55 | $supportFormats= |
54 | 56 | "FORMAT\\s+TSV|FORMAT\\s+TSVRaw|FORMAT\\s+TSVWithNames|FORMAT\\s+TSVWithNamesAndTypes|FORMAT\\s+Vertical|FORMAT\\s+JSONCompact|FORMAT\\s+JSONEachRow|FORMAT\\s+TSKV|FORMAT\\s+TabSeparatedWithNames|FORMAT\\s+TabSeparatedWithNamesAndTypes|FORMAT\\s+TabSeparatedRaw|FORMAT\\s+BlockTabSeparated|FORMAT\\s+CSVWithNames|FORMAT\\s+CSV|FORMAT\\s+JSON|FORMAT\\s+TabSeparated"; |
55 | 57 | |
@@ -63,8 +65,7 @@ discard block |
||
63 | 65 | $this->format=trim(str_ireplace('format','',$matches[0][0])); |
64 | 66 | |
65 | 67 | } |
66 | - } |
|
67 | - else { |
|
68 | + } else { |
|
68 | 69 | $this->sql = $this->sql . ' FORMAT ' . $this->format; |
69 | 70 | } |
70 | 71 |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @var array |
22 | 22 | */ |
23 | - private $degenerations=[]; |
|
23 | + private $degenerations = []; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Query constructor. |
27 | 27 | * @param string $sql |
28 | 28 | * @param array $degenerations |
29 | 29 | */ |
30 | - public function __construct($sql,$degenerations=[]) |
|
30 | + public function __construct($sql, $degenerations = []) |
|
31 | 31 | { |
32 | 32 | if (!trim($sql)) |
33 | 33 | { |
34 | 34 | throw new QueryException('Empty Query'); |
35 | 35 | } |
36 | 36 | $this->sql = $sql; |
37 | - $this->degenerations=$degenerations; |
|
37 | + $this->degenerations = $degenerations; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | { |
51 | 51 | // FORMAT\s(\w)*$ |
52 | 52 | if (null === $this->format) return false; |
53 | - $supportFormats= |
|
53 | + $supportFormats = |
|
54 | 54 | "FORMAT\\s+TSV|FORMAT\\s+TSVRaw|FORMAT\\s+TSVWithNames|FORMAT\\s+TSVWithNamesAndTypes|FORMAT\\s+Vertical|FORMAT\\s+JSONCompact|FORMAT\\s+JSONEachRow|FORMAT\\s+TSKV|FORMAT\\s+TabSeparatedWithNames|FORMAT\\s+TabSeparatedWithNamesAndTypes|FORMAT\\s+TabSeparatedRaw|FORMAT\\s+BlockTabSeparated|FORMAT\\s+CSVWithNames|FORMAT\\s+CSV|FORMAT\\s+JSON|FORMAT\\s+TabSeparated"; |
55 | 55 | |
56 | - $matches=[]; |
|
57 | - if (preg_match_all('%('.$supportFormats.')%ius',$this->sql,$matches)){ |
|
56 | + $matches = []; |
|
57 | + if (preg_match_all('%(' . $supportFormats . ')%ius', $this->sql, $matches)) { |
|
58 | 58 | |
59 | 59 | // skip add "format json" |
60 | 60 | if (isset($matches[0])) |
61 | 61 | { |
62 | 62 | |
63 | - $this->format=trim(str_ireplace('format','',$matches[0][0])); |
|
63 | + $this->format = trim(str_ireplace('format', '', $matches[0][0])); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | foreach ($this->degenerations as $degeneration) |
96 | 96 | { |
97 | 97 | if ($degeneration instanceof Degeneration) { |
98 | - $this->sql=$degeneration->process($this->sql); |
|
98 | + $this->sql = $degeneration->process($this->sql); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |