1.仓库地址 https://github.com/sanchezzzhak/kak-clickhouse
2.安装 composer require kak/clickhouse ~1.1
3.main.php文件中加入
'clickhouse' => [
'class' => 'kak\clickhouse\Connection',
'dsn' => '127.0.0.1',
'port' => '8123',
// 'database' => 'default', // use other database name
'username' => 'web',
'password' => '123',
'enableSchemaCache' => true,
'schemaCache' => 'cache',
'schemaCacheDuration' => 86400
],
4.控制器中:
$client = \Yii::$app->clickhouse;
$sql = 'select * from stat where counter_id=:counter_id';
$res = $client->createCommand($sql, [
':counter_id' => 122
])->queryAll();
输出$res,如果配置正确并且有结果,end。
完结。

发表回复