https://github.com/stereoflo/dbal-clickhouse
doctrine dbal layer for clickhouse.
https://github.com/stereoflo/dbal-clickhouse
clickhouse dbal symfony
Last synced: 5 months ago
JSON representation
doctrine dbal layer for clickhouse.
- Host: GitHub
- URL: https://github.com/stereoflo/dbal-clickhouse
- Owner: StereoFlo
- Created: 2021-12-03T15:26:05.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-09T18:49:07.000Z (over 4 years ago)
- Last Synced: 2025-01-23T02:14:08.053Z (over 1 year ago)
- Topics: clickhouse, dbal, symfony
- Language: PHP
- Homepage:
- Size: 467 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Installation
```
composer require stereoflo/dbal-clickhouse
```
## Initialization
### Symfony
configure...
```.dotenv
# .env
CLICKHOUSE_HOST=127.0.0.1
CLICKHOUSE_PORT=8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
```
```yml
# config/packages/doctrine.yaml
doctrine:
dbal:
dbname: default
host: '%env(resolve:CLICKHOUSE_HOST)%'
port: '%env(resolve:CLICKHOUSE_PORT)%'
user: '%env(resolve:CLICKHOUSE_USER)%'
password: '%env(resolve:CLICKHOUSE_PASSWORD)%'
driver_class: DBALClickHouse\Driver
wrapper_class: DBALClickHouse\Connection
options:
enable_http_compression: 1
max_execution_time: 60
```
...and get from the service container
```php
private Connection $connection;
public function __construct(Connection $connection)
{
$this->connection = $connection;
}
/**
* @return array>
*/
public function getByUserId(int $userId): array
{
$result = $this->connection
->createQueryBuilder()
->select('user.user_id')
->from('users', 'user')
->where('user.user_id = :user_id')
->setParameter('user_id', $userId)
->executeQuery();
return $result->fetchAllAssociative();
``