PHP code example of deflinhec / laravel-clickhouse
1. Go to this page and download the library: Download deflinhec/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/ */
deflinhec / laravel-clickhouse example snippets
use Deflinhec\LaravelClickHouse\Services\Service;
$clickHouse = new Service();
// Execute custom query
$result = $clickHouse->executeQuery('SELECT * FROM your_table LIMIT 10');
// Test connection
if ($clickHouse->testConnection()) {
echo "Connection successful!";
}
use Deflinhec\LaravelClickHouse\Database\Migration;
class CreateExampleTable extends Migration
{
public function up()
{
return <<<SQL
CREATE TABLE IF NOT EXISTS example_table (
id UInt32,
name String,
value Float64,
is_active UInt8 DEFAULT 1,
tags Array(String),
metadata String,
created_at DateTime DEFAULT now(),
updated_at DateTime DEFAULT now()
) ENGINE = MergeTree()
ORDER BY (id, created_at)
SQL;
}
public function down()
{
return <<<SQL
DROP TABLE IF EXISTS example_table
SQL;
}
}