Download the PHP package arungowda325/clickhouse-query-builder without Composer

On this page you can find all versions of the php package arungowda325/clickhouse-query-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package clickhouse-query-builder

Clickhouse Query Builder

Build Status Coverage Status

Requirements

php 7.1+

Install

Via composer

Usage

For working query builder we must previously instantiate and pass in constructor arungowda325/clickhouse-php-client.

After that we can build and perform sql queries.

Select columns

All this calls will be transformed into next sql:

Also, as a column we can pass closure. In this case in closure will be passed instance of Column class, inside which we can setup column how we want. This can be useful for difficult expressions with many functions, subqueries and etc.

Will be compiled in:

Will be compiled in:

Same behavior can be also achieved by any of the following approaches:

Notice! Functions on columns is not stable and under development.

From

Produce the following query:

Also can be passed closure or builder as argument for performing sub query.

or

or

or

It is all variants of the same sql query which was listed above.

Sample coefficient

I think there no need for additional words)

Joins

For performing subquery as first argument you can pass closure or builder.

Also there are many helper functions with hardcoded arguments, like strict or type and they combinations.

You can use array join as well.

Temporary tables usage

There are some cases when you need to filter f.e. users by their ids, but amount of ids is huge. You can store users ids in local file, upload it to server and use it as temporary table.

Read more about local files here in section Using local files.

Select

You should pass instance of TempTable with declared table structure to attach file to query.

If you want tables to be detected automatically, call addFile method before calling whereIn.

You can use local files in whereIn, prewhereIn, havingIn and join statements of query builder.

Insert

If you want to insert file or files into Clickhouse, you could use insertFile and insertFiles methods.

Or you can pass batch of files into insertFiles method and all of them will be inserted asynchronously.

Also, you can use helper and insert data to temporary table with engine Memory.

Helper will drop temporary table with name test and creates table with declared structure, engine Memory and inserts data from test.tsv file into just created table.

It's helpful if you want to fill some table with data to execute query and then drop it.

Prewhere, where, having

All example will be about where, but same behavior also is for prewhere and having.

All string values will be wrapped with single quotes. If operator is not provided = will be used. If operator is not provided and value is an array, then IN will be used.

If in the first argument was passed closure, then all wheres statements from inside will be wrapped with parenthesis. But if on that builder (inside closure) will be specified from then it will be transformed into subquery.

Almost same is for value parameter, except wrapping into parenthesis. Any closure or builder instance passed as value will be converted into subquery.

Also you can pass internal representation of this statement and it will be used. I will no talk about this with deeper explanation because its not preferable way to use this.

Like joins there are many helpers with hardcoded parameters.

Also there is method to make where by dictionary:

If you want to use complex key, you may pass an array as $key, then array will be converted to tuple. By default all strings will be escaped by single quotes, but you may pass an Identifier instance to pass for example column name:

Will produce:

Group By

Works like select.

Final query will be like:

Order By

In the example above, third argument is optional

Aliases:

For column there are same behaviour like in select method.

Limit

There are two types of limit. Limit and limit n by.

Limit n by:

Will produce:

Simple limit:

Will produce:

Union ALL

In unionAll method can be passed closure or builder instance. In case of closure inside will be passed builder instance.

Performing request and getting result.

After building request you must call get() method for sending request to the server. Also there has opportunity to make asynchronous requests. Its works almost like unionAll.

This callings will produce the same behavior. Two queries which will be executed asynchronous. Now, if you call get() method, as result will be returned array, where numeric index correspond to the result of request with this number.

Integrations

Laravel or Lumen < 5.5

You can use this builder in Laravel/Lumen applications.

Laravel

In config/app.php add:

Lumen

In bootstrap/app.php add:

Connection configures via config/database.php.

Example with alone server:

Get a new builder:

or

Example with cluster:

Example with server with tag:

Choose server without cluster:

Or execute each new query on random server:

Choose cluster:

Use server with tag:

You can use both servers and clusters config directives and choose on which server query should be executed via onCluster and using methods. If you want to choose server outside cluster, you should just call onCluster(null) and then call using method. You can call usingRandomServer and using methods with selected cluster or not.


All versions of clickhouse-query-builder with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
myclabs/php-enum Version ^1.5
arungowda325/clickhouse-php-client Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package arungowda325/clickhouse-query-builder contains the following files

Loading the files please wait ....