PHPackages                             lucasacoutinho/ext-clickhouse-pdo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. lucasacoutinho/ext-clickhouse-pdo

ActivePhp-ext[Database &amp; ORM](/categories/database)

lucasacoutinho/ext-clickhouse-pdo
=================================

PDO driver for ClickHouse using the native TCP protocol.

v1.0.7(1mo ago)00[3 PRs](https://github.com/lucasacoutinho/ext-clickhouse-pdo/pulls)MITC++PHP &gt;=7.4 &lt;8.6CI passing

Since May 27Pushed 1mo agoCompare

[ Source](https://github.com/lucasacoutinho/ext-clickhouse-pdo)[ Packagist](https://packagist.org/packages/lucasacoutinho/ext-clickhouse-pdo)[ RSS](/packages/lucasacoutinho-ext-clickhouse-pdo/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (8)DependenciesVersions (12)Used By (0)

pdo\_clickhouse
===============

[](#pdo_clickhouse)

A PDO driver for ClickHouse using the native TCP protocol (port 9000). Built on top of [ext-clickhouse](https://github.com/lucasacoutinho/ext-clickhouse) and [clickhouse-cpp](https://github.com/ClickHouse/clickhouse-cpp).

Requirements
------------

[](#requirements)

- PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, or 8.5
- [ext-clickhouse](https://github.com/lucasacoutinho/ext-clickhouse) (must be installed first)

PHP version support
-------------------

[](#php-version-support)

CI builds and tests the driver on PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, and 8.5.

`pdo_clickhouse` uses headers installed by `ext-clickhouse`. A sibling `../ext-clickhouse` checkout is still supported for local development, but users should install the native extension first.

PDO releases depend on `ext-clickhouse` releases, not directly on `clickhouse-cpp`. Release images pin the native extension ref instead of building from a floating branch.

Build
-----

[](#build)

```
git clone https://github.com/lucasacoutinho/ext-clickhouse-pdo.git
cd ext-clickhouse-pdo

# ext-clickhouse must be installed first; a sibling ../ext-clickhouse checkout
# is also supported for local development.

phpize
./configure --enable-pdo-clickhouse
make
make install
```

Add to your `php.ini` (after `extension=clickhouse`):

```
extension=pdo_clickhouse
```

Install with PIE
----------------

[](#install-with-pie)

```
pie install lucasacoutinho/ext-clickhouse
pie install lucasacoutinho/ext-clickhouse-pdo
```

Usage
-----

[](#usage)

```
$pdo = new PDO('clickhouse:host=127.0.0.1;port=9000;dbname=default', 'default', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

// Query
$stmt = $pdo->query('SELECT number, toString(number) AS str FROM system.numbers LIMIT 5');
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

// Prepared statements (emulated)
$stmt = $pdo->prepare('SELECT * FROM my_table WHERE id = :id');
$stmt->bindValue('id', 42);
$stmt->execute();

// DDL
$pdo->query('CREATE TABLE IF NOT EXISTS test (id UInt64, name String) ENGINE = Memory');

// INSERT
$pdo->query("INSERT INTO test VALUES (1, 'Alice'), (2, 'Bob')");
```

### TLS DSN Options

[](#tls-dsn-options)

Boolean DSN options accept `1`, `0`, `true`, `false`, `yes`, `no`, `on`, and `off` case-insensitively. Invalid values are rejected.

```
$pdo = new PDO(
    'clickhouse:host=host.example.com;port=9440;dbname=default;ssl=on;ca_file=/path/to/ca.pem;client_cert=/path/to/client.crt;client_key=/path/to/client.key',
    'default',
    'secret'
);
```

Supported TLS options: `ssl`, `skip_verify`, `ca_path`, `ca_file`, `client_cert`, and `client_key`. System CA locations and SNI are enabled when `ssl` is enabled.

Docker
------

[](#docker)

Pre-built images are available on GitHub Container Registry:

```
docker pull ghcr.io/lucasacoutinho/ext-clickhouse-pdo:php8.5-latest
```

Running tests
-------------

[](#running-tests)

```
# Requires a running ClickHouse instance and ext-clickhouse installed
CLICKHOUSE_HOST=127.0.0.1 make test
```

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

8

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6688cf7dabb10961bde68df0ed41ff2efecec6ae8c37b0feaa1201b100c9681?d=identicon)[kairos-php](/maintainers/kairos-php)

---

Top Contributors

[![lucasacoutinho](https://avatars.githubusercontent.com/u/69213256?v=4)](https://github.com/lucasacoutinho "lucasacoutinho (20 commits)")

### Embed Badge

![Health badge](/badges/lucasacoutinho-ext-clickhouse-pdo/health.svg)

```
[![Health](https://phpackages.com/badges/lucasacoutinho-ext-clickhouse-pdo/health.svg)](https://phpackages.com/packages/lucasacoutinho-ext-clickhouse-pdo)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
