Download the PHP package earc/query-language without Composer

On this page you can find all versions of the php package earc/query-language. 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 query-language

eArc-query-language

This is the lightweight standalone (zero dependencies) find/select query language component of the eArc framework.

Its full type hint support and its sql-like syntax make it easy to learn and easy to use.

You can bind this component to any database or index that supports some kind of categories (e.g. tables) and is able to resolve the following relations:

You may use only a subset of the relations or only one single category if you like.

installation

Install the earc dependency injection library by using composer.

binding

To bind the language to your database/index implement the ResolverInterface. If you use the AbstractResolver only three methods need implementation: findAll(), queryRelation() and sort().

The returned iterable has to use for the keys unique data identifier strings and as values the data items.

HINT: The unique data identifiers have to contain one non integer character, otherwise PHP would transform the string key to an integer.

You may use several distinct bindings in your project. That is why the resolver has to be bound to your query factory. Just extend the AbstractQueryFactory and implement the getQueryResolver() method.

To inject your resolver you can use traditional constructor injection or use some more sophisticated tool like earc/di.

usage

simple usage

The simple usage has been inspired by the findBy() method of the doctrine repositories.

This gives all data entries of the data category SomeCategory.

This gives all data entries of the data category Wallpaper having the value green for the property color and true for the property available.

Internally this resolves to a Query...

query based usage

You can use the query language directly by using find() instead of findBy(). find() does return a QueryInitializer you can build your query from.

The first query part is always from. Here you specify the data category.

You can specify an optional limit as second query part.

The $limit is an int and specifies the maximal number of returned data items. The $offset is an int too and specifies the position of the first item. limit is especially handy for all kinds of pagination.

The third query part is optional too. It specifies the sorting of the returned data items. Of course limit is applied after sorting.

You may pass as many properties as you wish. The data items will be sorted by the first property, if this is equal for some items they will be sorted by the second property and so on.

HINT: Sort has to be implemented in the resolver. Its implementation may differ from the behaviour explained here.

After this there is always either an eval or a where expression. eval would return at this point all data items of the data category specified by from (only influenced by the optional limit and sort). Whereas where introduces a relation which may thin out the data items of the result. It takes a property name as argument.

The where expression has to be chained to one of the following relations:

This expression can be evaluated via eval() or chained by a second where and a logical conjunction prefix:

These are followed by another relation and will be evaluated via eval() or chained by another andWhere() or orWhere and so on.

If the AbstractResolver is used by the resolver andWhere() conjunctions will be evaluated before orWhere() conjunctions.

In case you need another behaviour you can use the BRACKETS() method instead of where(), AND() instead of andWhere() and OR() instead of orWhere(). They take a query expression as argument which is evaluated first and in the case of AND() and OR() thereafter applied to the result of the expression on the left.

You can use the same instance of QueryPart for all your bracket expressions. (It is an object without properties.)

the result

If the resolver uses the AbstractResolver eval() returns a QueryResult. To retrieve the data items you have to iterate over it.

restrict the result

Both find() and findBy() take as last argument an iterable $allowedDataIdentifiers which restrict the returned result to the data items pointed at by the allowed data identifiers.

releases

release 0.1

release 0.0


All versions of query-language with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0 || ^7.2
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 earc/query-language contains the following files

Loading the files please wait ....