PHP code example of bavix / laravel-clickhouse
1. Go to this page and download the library: Download bavix/laravel-clickhouse 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/ */
bavix / laravel-clickhouse example snippets
Bavix\LaravelClickHouse\ClickHouseServiceProvider::class,
'connections' => [
'bavix::clickhouse' => [
'driver' => 'bavix::clickhouse',
'host' => '',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
]
]
]
'connections' => [
'bavix::clickhouse' => [
'driver' => 'bavix::clickhouse',
'servers' => [
[
'host' => 'ch-00.domain.com',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
]
],
[
'host' => 'ch-01.domain.com',
'port' => '',
'database' => '',
'username' => '',
'password' => '',
'options' => [
'timeout' => 10,
'protocol' => 'https'
]
]
]
]
],
use Bavix\LaravelClickHouse\Database\Eloquent\Model;
class Payment extends Model
{
protected $table = 'payments';
}
Payment::select(raw('count() AS cnt'), 'payment_system')
->whereBetween('payed_at', [
Carbon\Carbon::parse('2017-01-01'),
now(),
])
->groupBy('payment_system')
->get();