prageeth-peiris / laravel-query-builder-to-clickhouse
一个简单的包,用于在Yandex ClickHouse数据库中执行由Laravel查询构造器提供的原始SQL查询。
1.10
2024-09-05 10:55 UTC
Requires
- php: ^8.0
- bavix/laravel-clickhouse: ^2.0 | ^2.3
- illuminate/support: ^8.0 | ^10.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
您可以通过composer安装此包
composer require prageeth-peiris/laravel-query-builder-to-clickhouse
用法
// Usage description here //Add following database connections to config/database.php 'bavix::clickhouse' => [ 'driver' => 'bavix::clickhouse', 'host' => env('CLICKHOUSE_HOST'), 'port' => env('CLICKHOUSE_PORT',8123), 'database' => env('CLICKHOUSE_DATABASE'), 'username' => env('CLICKHOUSE_USER','default'), 'password' => env('CLICKHOUSE_PASSWORD'), 'options' => [ 'timeout' => 20, 'protocol' => 'http' ] ], 'clickhouse_custom' => [ 'driver' => 'bavix::clickhouse::custom', 'host' => env('CLICKHOUSE_HOST'), 'port' => env('CLICKHOUSE_PORT',8123), 'database' => env('CLICKHOUSE_DATABASE'), 'username' => env('CLICKHOUSE_USER','default'), 'password' => env('CLICKHOUSE_PASSWORD'), 'options' => [ 'timeout' => 20, 'protocol' => 'http' ] ] //extend from this model and start using clickhouse use PrageethPeiris\LaravelQueryBuilderToClickhouse\Model; Class CustomModel extends BaseClickHouseModel { //this is required if you are doing sub query joining protected $tableJoinKey = 'page'; } //use table with a suffix at runtime CustomModel::useTableSuffix("in_memory")->insert($data) //here comes a method to do sub query joining very easily CustomModel::autoLeftJoinSubQuery(CustomModel::class,OtherModel::GroupBySomething()) ->autoLeftJoinSubQuery(CustomModel::class,OtherModel::GroupBySomethingAndSomething())
注意
这是一个有观点的包,因此通过原始ClickHouse SQL查询缓存结果。它将使用您的默认缓存驱动程序。要清除缓存,请运行 php artisan cache:clear
依赖项
- PHP 8
- Laravel 8
- https://github.com/bavix/laravel-clickhouse
- https://github.com/MariosTheof/laravel-clickhouse-migrations
阅读相关包的文档以使用其配置。
变更日志
请参阅CHANGELOG以获取更多有关最近更改的信息。
贡献
请参阅CONTRIBUTING以获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件glpspeiris@gmail.com联系,而不是使用问题跟踪器。
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。
Laravel Package Boilerplate
此包使用Laravel Package Boilerplate生成。