one23/laravel-clickhouse 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

one23/laravel-clickhouse

最新稳定版本:v0.1.4

Composer 安装命令:

composer require one23/laravel-clickhouse

包简介

Laravel Clickhouse Eloquent

README 文档

README

Install

composer require one23/laravel-clickhouse

Add provider to bootstrap/providers.php

return [ //... One23\LaravelClickhouse\ClickhouseServiceProvider::class, //... ];

Add connection to config/database.php

return [ 'connections' => [ //... 'clickhouse' => [ 'driver' => 'clickhouse', 'host' => env('CLICKHOUSE_HOST', 'localhost'), 'port' => env('CLICKHOUSE_PORT', 8123), 'database' => env('CLICKHOUSE_DATABASE'), 'username' => env('CLICKHOUSE_USERNAME'), 'password' => env('CLICKHOUSE_PASSWORD'), 'options' => [ 'timeout' => 15, 'protocol' => 'http', ], ], //... ] ];

Create model. Example:

use One23\LaravelClickhouse\Database\Eloquent\Model; class StatisticDaily extends Model { protected $table = 'mv_statistic_daily'; protected $casts = [ 'date' => 'date', 'link_id' => 'int', 'cnt' => 'int', 'uniq_ip' => 'int', ]; protected $primaryKey = null; // }

Use model. Example:

Clickhouse\StatisticDaily::query() ->where('date', '=', $dt) ->delete(); Clickhouse\StatisticDaily::query() ->where('link_id', '=', $OLink->getId()) ->whereBetween('date', [ $from->startOfDay()->toDateString(), $to->endOfDay()->toDateString(), ]) ->groupBy('date') ->selectRaw(implode(', ', [ '`date`', 'SUM(`cnt`) AS `cnt`', 'SUM(`cnt_uniq_ip`) AS `cnt_uniq_ip`', 'SUM(`cnt_uniq`) AS `cnt_uniq`', 'SUM(`cnt_mobile`) AS `cnt_mobile`', 'AVG(`avg_latency`) AS `avg_latency`', 'MIN(NULLIF(`min_latency`, 0)) AS `min_latency`', 'MAX(`max_latency`) AS `max_latency`', 'AVG(`quantile_latency`) AS `quantile_latency`', ])) ->get(); Clickhouse\StatisticDaily::query() ->whereIn('link_id', $linkIds) ->whereBetween('date', [ $this->from ->toDateString(), $this->to ->toDateString(), ]) ->selectRaw(implode(', ', [ 'SUM(`statistic_daily`.`cnt`) as `cnt`', 'SUM(`statistic_daily`.`cnt_uniq_ip`) as `cnt_uniq_ip`', ])) ->first();

Todo

  • Tests
  • Deep where's
  • Rewrite Grammar
  • ...

Security

If you discover any security related issues, please email eugene@krivoruchko.info instead of using the issue tracker.

License

MIT

统计信息

  • 总下载量: 6.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固