|
1 | | -# SeasClick |
2 | 1 | SeasClick |
| 2 | +===== |
| 3 | +[](https://travis-ci.org/SeasX/SeasClick) |
| 4 | + |
| 5 | +PHP client for [Yandex ClickHouse](https://clickhouse.yandex/),Based on [ClickHouse C++ client](https://github.com/aiwhj/clickhouse-cpp) |
| 6 | + |
| 7 | +## ClickHouse |
| 8 | +* [What is ClickHouse](https://clickhouse.yandex/docs/en/) |
| 9 | +* [ClickHouse Performance](https://clickhouse.yandex/docs/en/introduction/performance/) |
| 10 | +* [Performance comparison with MySQL](https://clickhouse.yandex/benchmark.html#[%22100000000%22,[%22ClickHouse%22,%22MySQL%22],[%220%22,%221%22]]) |
| 11 | + |
| 12 | +## Supported data types |
| 13 | + |
| 14 | +* Array(T) |
| 15 | + **Multidimensional arrays are not supported at this time** |
| 16 | +* Date |
| 17 | +* DateTime |
| 18 | +* Enum8, Enum16 |
| 19 | +* FixedString(N) |
| 20 | +* Float32, Float64 |
| 21 | +* Nullable(T) |
| 22 | +* String |
| 23 | +* UInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64 |
| 24 | + |
| 25 | +## Supported PHP version |
| 26 | +PHP 5.5+ |
| 27 | + |
| 28 | +## Performance |
| 29 | + |
| 30 | + |
| 31 | +This performance test [demo](https://github.com/SeasX/SeasClick/blob/master/tests/bench_mark/bench_mark.php) is compared to [phpclickhouse](https://github.com/smi2/phpClickHouse) |
| 32 | + |
| 33 | +## Install |
| 34 | +```ssh |
| 35 | +git clone https://github.com/SeasX/SeasClick.git |
| 36 | +git submodule init |
| 37 | +git submodule update |
| 38 | +cd SeasClick |
| 39 | +phpize |
| 40 | +./configure |
| 41 | +make && make install |
| 42 | +``` |
| 43 | + |
| 44 | +## Example |
| 45 | + |
| 46 | +```php |
| 47 | +<?php |
| 48 | +$config = [ |
| 49 | + "host" => "clickhouse", |
| 50 | + "port" => 9000, |
| 51 | + "compression" => true |
| 52 | +]; |
| 53 | + |
| 54 | +clientTest($config); |
| 55 | + |
| 56 | +function clientTest($config) |
| 57 | +{ |
| 58 | + $deleteTable = true; |
| 59 | + $client = new SeasClick($config); |
| 60 | + |
| 61 | + $client->execute("CREATE DATABASE IF NOT EXISTS test"); |
| 62 | + |
| 63 | + testArray($client, $deleteTable); |
| 64 | +} |
| 65 | + |
| 66 | +function testArray($client, $deleteTable = false) { |
| 67 | + $client->execute("CREATE TABLE IF NOT EXISTS test.array_test (string_c String, array_c Array(Int8), arraynull_c Array(Nullable(String))) ENGINE = Memory"); |
| 68 | + |
| 69 | + $client->insert("test.array_test", [ |
| 70 | + 'string_c', 'array_c', 'arraynull_c' |
| 71 | + ], [ |
| 72 | + ['string_c1', [1, 2, 3], ['string']], |
| 73 | + ['string_c2', [4, 5, 6], [null]] |
| 74 | + ]); |
| 75 | + |
| 76 | + $result = $client->select("SELECT {select} FROM {table}", [ |
| 77 | + 'select' => 'string_c, array_c, arraynull_c', |
| 78 | + 'table' => 'test.array_test' |
| 79 | + ]); |
| 80 | + var_dump($result); |
| 81 | + |
| 82 | + if ($deleteTable) { |
| 83 | + $client->execute("DROP TABLE {table}", [ |
| 84 | + 'table' => 'test.array_test' |
| 85 | + ]); |
| 86 | + } |
| 87 | +} |
| 88 | +``` |
| 89 | +#### [More examples](https://github.com/SeasX/SeasClick/tests/test.php) |
| 90 | + |
| 91 | +## Support |
| 92 | +SeasX Group |
0 commit comments