stereoflo / dbal-clickhouse
Doctrine DBAL driver for ClickHouse
v1.0.1
2021-12-07 18:42 UTC
Requires
- php: ^7.4
- doctrine/dbal: ^3.2
- smi2/phpclickhouse: ^1.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^0.12
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2025-03-10 01:54:10 UTC
README
composer require stereoflo/dbal-clickhouse
Initialization
Symfony
configure...
# .env
CLICKHOUSE_HOST=127.0.0.1
CLICKHOUSE_PORT=8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
# 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
private Connection $connection; public function __construct(Connection $connection) { $this->connection = $connection; } /** * @return array<array<string, string>> */ 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(); ``