Download the PHP package aozeahj/phpclickhouse without Composer
On this page you can find all versions of the php package aozeahj/phpclickhouse. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aozeahj/phpclickhouse
More information about aozeahj/phpclickhouse
Files in aozeahj/phpclickhouse
Package phpclickhouse
Short Description php ClickHouse client library
License MIT
Homepage https://github.com/smi2/phpClickHouse
Informations about the package phpclickhouse
PHP ClickHouse wrapper
Features
- No dependency, only curl (php 5.6 without composer)
- Select parallel queries (asynchronous)
- Parallelizing bulk inserts from CSV file
- enable_http_compression, for bulk inserts
- Find active host and check cluster
- Select WHERE IN ( local csv file )
- SQL conditions & template
- tablesSize & databaseSize
- listPartitions
- dropPartition & dropOldPartitions
- truncateTable in cluster
- Insert array as column
- Get master node replica in cluster
- Get tableSize in all nodes
- Async get ClickHouse progress function
Russian articles in repo, on habr 2 on habr 1
Install composer
OR install submodule
composer
require php 7.1, but phpClickHouse can work on php >=5.6 without autoload and composer
In php
Start
Connect and select database:
Show tables:
Create table:
Show create table:
Insert data:
Select:
Work with Statement:
Select result as tree:
Drop table:
Features
Select parallel queries (asynchronous)
Parallelizing massive inserts from CSV file
Parallelizing errors
selectAsync without executeAsync
see example/exam5_error_async.php
Gzip & enable_http_compression
On fly read CSV file and compress zlib.deflate.
see speed test example/exam08_http_gzip_batch_insert.php
Max execution time
tablesSize & databaseSize
Result in human size
Partitions
Drop partitions ( pre production )
Select WHERE IN ( local csv file )
Simple sql conditions & template
conditions is deprecated, if need use:
$db->enableQueryConditions();
Example with QueryConditions:
Example custom query Degeneration in exam16_custom_degeneration.php
Settings
3 way set any settings
Use session_id with ClickHouse
useSession()
- make new session_id or use exists useSession(value)
Array as column
Class for FormatLine array
Cluster drop old Partitions
Example code :
HTTPS
ReadOnly ClickHouse user
Direct write to file
Send result from clickhouse, without parse json.
insert Assoc Bulk
progressFunction
Cluster
Return Extremes
Enable Log Query
You can log all query in ClickHouse
isExists
Debug & Verbose
Dev & PHPUnit Test
- Don't forget to run composer install. It should setup PSR-4 autoloading.
- Then you can simply run vendor/bin/phpunit and it should output the following
In phpunit.xml change constants:
Run test
Run PHPStan
License
MIT
ChangeLog
2018-05-09
- Move
\ClickHouseDB\WhereInFile
to\ClickHouseDB\Query\WhereInFile
- Move
\ClickHouseDB\QueryException
to\ClickHouseDB\Exception\QueryException
- Move
\ClickHouseDB\DatabaseException
toClickHouseDB\Exception\DatabaseException
- Move
\ClickHouseDB\FormatLine
to\ClickHouseDB\Quote\FormatLine
- Move
\ClickHouseDB\WriteToFile
toClickHouseDB\Query\WriteToFile
- Move
\Curler\Request
to\ClickHouseDB\Transport\CurlerRequest
- Move
\Curler\CurlerRolling
to\ClickHouseDB\Transport\CurlerRolling
- Up to php 7.2 & phpunit 7.1 for Dev & Prs4 Autoloading
2018-03-26
- Fix StreamInsert : one stream work faster and safe than loop #PR43
- Fix cluster->clientLike()
2017-12-28
- Fix
FORMAT JSON
if set FORMAT in sql - GetRaw() - result raw response if not json
SELECT number as format_id FROM system.numbers LIMIT 3 FORMAT CSVWithNames
2017-12-22
- progressFunction()
- Escape values
2017-12-12
- Not set
FORMAT JSON
if set FORMAT in sql
2017-11-22
- Add insertAssocBulk
2017-08-25
- Fix tablesSize(), use database filter
- Fix partitions(), use database filter
2017-08-14
- Add session_id support
2017-02-20
- Build composer 0.17.02
2016-12-09
- for ReadOnly users need set :
client->setReadOnlyUser(true);
or$confi['readonly']
, see exam19_readonly_user.php
2016-11-25
client->truncateTable('tableName')
cluster->getMasterNodeForTable('dbName.tableName') // node have is_leader=1
cluster->getSizeTable('dbName.tableName')
cluster->getTables()
cluster->truncateTable('dbName.tableName')
- See example cluster_06_truncate_table.php
2016-11-24
- add
cluster->setSoftCheck()
- insertBatchFiles() support
$file_names
- string or array ,$columns_array
- array or null - add insertBatchStream() return
\Curler\Request
no exec - writeStreamData() return
\Curler\Request
- fix httpCompression(false)
- getHeaders() as array from
\Curler\Request
setReadFunction( function() )
inRequest
- Add class StreamInsert, direct read from stream_resource to clickhouse:stream
2016-11-04
- add
$db->insertBatchTSVFiles()
, - add format param in
$db->insertBatchFiles(,,,format)
, - deprecated class CSV
- Add static class
\ClickHouseDB\FormatLine:CSV(),\ClickHouseDB\FormatLine:TSV(),\ClickHouseDB\FormatLine:Insert()
- CSV RFC4180 -
\ClickHouseDB\FormatLine::CSV(Array))."\n"
- Update exam12_array.php + unit tests
2016-11-03
$db->enableLogQueries(true)
- write to system.query_log$db->enableExtremes(true);
- default extremes now, disabled$db->isExists($database,$table)
2016-10-27
- add Connect timeout , $db->setConnectTimeOut(5);
- change default ConnectTimeOut = 5 seconds. before 1 sec.
- change DNS_CACHE default to 120 seconds
2016-10-25 Release 0.16.10
- fix timeout error and add test
2016-10-23
- client->setTimeout($seconds)
- cluster->clientLike($cluster,$ip_addr_like)
- Delete all migration code from driver, move to https://github.com/smi2/phpMigrationsClickhouse
2016-09-20 Release 0.16.09
- Version/Release names: [ zero dot year dot month]
- Support cluster: new class Cluster and ClusterQuery
- output_format_write_statistics, for clickhouse version > v1.1.54019-stable
- WriteToFile in select,selectAsync
- Degeneration for Bindings & Conditions
- $db->select(new Query("Select..."));
- remove findActiveHostAndCheckCluster , clusterHosts , checkServerReplicas
- Add cleanQueryDegeneration(),addQueryDegeneration()
- Need $db->enableQueryConditions(); for use Conditions ; default Conditions - disabled;
- float in CurlerRequest->timeOut(2.5) = 2500 ms
- tablesSize() - add
sizebytes
2016-08-11 Release 0.2.0
- exception on error write
2016-08-06 Release 0.1.0
- init
All versions of phpclickhouse with dependencies
ext-curl Version *