1. Go to this page and download the library: Download esazykin/clickhouse-builder library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
esazykin / clickhouse-builder example snippets
$server = new Tinderbox\Clickhouse\Server('127.0.0.1', '8123', 'default', 'user', 'pass');
$client = new Tinderbox\Clickhouse\Client($server);
$builder = new Builder($client);
$builder->select('column', 'column2', 'column3 as alias');
$builder->select(['column', 'column2', 'column3 as alias']);
$builder->select(['column', 'column2', 'column3' => 'alias']);
$builder->select(function ($column) {
$column->as('alias') //or ->name('alias') in this case
->query()
->select('column')
->from('table');
});
$1 = $builder->select(function ($column) {
$column->as('alias') //or ->name('alias') in this case
->query(function ($query) {
$query->select('column')->from('table');
})
});
$2 = $builder->select(function ($column) {
$column->as('alias') //or ->name('alias') in this case
->query($builder->select('column')->from('table'));
});
/*
* Add file with users ids to builder as _users table
* Also, we must define data structure in file. In example below
* structure will be like ['UInt64']
*/
$builder->addFile('users.csv', '_users', ['UInt64']);
$builder->select(raw('count()'))->from('clicks')->whereIn('userId', new Identifier('_users'));