1. Go to this page and download the library: Download iliaal/php_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/ */
iliaal / php_clickhouse example snippets
$ch = new ClickHouse([
"host" => "127.0.0.1",
"port" => 9000,
"database" => "test",
"user" => "default",
"passwd" => "",
"compression" => "lz4", // or "zstd" / true / false
]);
$ch->execute("CREATE TABLE IF NOT EXISTS events (
id UInt32, ts DateTime64(3), tag LowCardinality(String)
) ENGINE = Memory");
$ch->insert("events", ["id", "ts", "tag"], [
[1, time(), "alpha"],
[2, time(), "beta"],
]);
foreach ($ch->select("SELECT id, ts, tag FROM events ORDER BY id",
[], ClickHouse::DATE_AS_STRINGS) as $row) {
print_r($row);
}
sh
pie install iliaal/php_clickhouse
sh
pie install iliaal/php_clickhouse --enable-clickhouse-openssl
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.