1 | <?php |
||
7 | class Clickhouse |
||
8 | { |
||
9 | use Toolkit; |
||
10 | |||
11 | public $bucketSize = 1000; |
||
12 | |||
13 | 2 | public function select($fields, string $table, array $params = []) |
|
14 | { |
||
15 | 2 | if (is_array($fields)) { |
|
16 | $fields = implode(', ', $fields); |
||
17 | } |
||
18 | |||
19 | 2 | $query = "SELECT $fields FROM $table"; |
|
20 | 2 | $binds = []; |
|
21 | |||
22 | 2 | if (count($params)) { |
|
23 | 1 | $where = []; |
|
24 | 1 | foreach ($params as $k => $v) { |
|
25 | 1 | $v = (array) $v; |
|
26 | 1 | if (count($v) == 1) { |
|
27 | 1 | $binds[$k] = $v[0]; |
|
28 | 1 | $where[] = $k.' = :'.$k; |
|
29 | } else { |
||
30 | $binds[$k] = $v; |
||
31 | $where[] = $k.' in (:'.$k.')'; |
||
32 | } |
||
33 | } |
||
34 | |||
35 | 1 | $where = implode(' and ', $where); |
|
36 | |||
37 | 1 | $query .= " where $where"; |
|
38 | } |
||
39 | |||
40 | 2 | return $this->get(Client::class)->select($query, $binds); |
|
41 | } |
||
42 | |||
43 | 2 | public function insert(string $table, array $data, array $headers) |
|
58 | } |
||
59 |