@@ -2,6 +2,15 @@ Extension ClickHouse for Yii 2
22==============================
33
44This extension provides the [ ClickHouse] ( https://clickhouse.yandex/ ) integration for the [ Yii framework 2.0] ( http://www.yiiframework.com ) .
5+ Main features:
6+ - SQL commands
7+ - Query builder
8+ - Schema builder
9+ - Migrations
10+ - Batch Insert
11+ - Parallel insert from large CSV files
12+ - Valid handling of UInt64 type in PHP
13+ - Supports Decimals and Nullable fields
514
615[ ![ Build Status] ( https://travis-ci.org/bashkarev/clickhouse.svg?branch=master )] ( https://travis-ci.org/bashkarev/clickhouse )
716
@@ -84,23 +93,27 @@ yii clickhouse-migrate
8493# reverts the last applied migration
8594yii clickhouse-migrate/down
8695```
96+ Access to native SMI2 ClickHouse client
97+ ---------------------------------------
98+ ``` php
99+ $client = \Yii::$app->clickhouse->getClient();
100+ ```
87101
88102Insert csv files
89103----------------
90104
91105> Files are uploaded in parallel.
92106
93107``` php
94- /**
95- * @var \bashkarev\clickhouse\InsertFiles $insert
96- */
97- $insert = Yii::$app->clickhouse->createCommand()->batchInsertFiles('csv',[
98- '@vendor/bashkarev/clickhouse/tests/data/csv/e1e747f9901e67ca121768b36921fbae.csv',
99- '@vendor/bashkarev/clickhouse/tests/data/csv/ebe191dfc36d73aece91e92007d24e3e.csv',
100- ]);
101- $insert
102- ->setFiles(fopen('/csv/ebe191dfc36d73aece91e92007d24e3e.csv','rb'))
103- ->setChunkSize(8192) // default 4096 bytes
104- ->execute();
108+ $db = \Yii::$app->clickhouse;
109+ $client = $db->getClient();
110+
111+ $results = $client->insertBatchFiles('table_name', ['file_with_data.csv']);
112+
113+ $state = $results['file_with_data.csv'];
114+ $isSuccess = !$state->isError();
115+ $uploadInfo = $state->responseInfo();
116+
117+ print_r($uploadInfo);
105118```
106119
0 commit comments