Download the PHP package cekurte/rql without Composer
On this page you can find all versions of the php package cekurte/rql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rql
RQL (Resource Query Language)
- A Resource Query Language to PHP (with all methods covered by php unit tests), with this library you can perform queries using a unique input interface that will be converted and processed using the ProcessorInterface contribute with this project!
Installation
- The package is available on Packagist.
- The source files is PSR-2 compatible.
- Autoloading is PSR-4 compatible.
- Input parser data is PSR-7 compatible.
If you liked of this library, give me a star =).
Documentation
This library was created to perform queries using a unique interface that will be converted and processed to the correct target. The target data can be an array, a database, a file (such as an ini, a xml or a json), a webservice, and more. Currently this project works only with the Doctrine ORM, then, you can perform queries in all databases that are compatible with the doctrine ORM project.
We would be happy with their contribution, submit your pull request for new Processors like the Eloquent ORM, File Parser (INI, XML, JSON), API's (Facebook, LinkedIn,...) and more.
Expressions
Well, now we show how to use this library, to perform the query using the equality expression (more expressions will be show too).
Ok, but why do not use the Doctrine QueryBuilder to build the queries and perform it? Because of the flexibility to search in the multiple data sources using the same interface changing the Processor class, that in this case is the DoctrineOrmProcessor.
Woow, you can see this scenario with various possibilities like me? Then, this library is for you guy. You share your aim with me and contribute with this project.
But, if i want build a collection of expression, i need to put the expressions using the queue? Yes, it is an valid answer for this question, but you can use the ExprBuilder to perform it too. Like the following example:
Note that the ExprBuilder class implements a shortcut to all available expressions.
Currently are available the following expressions:
- BetweenExpr
- EqExpr
- GteExpr
- GtExpr
- InExpr
- LikeExpr
- LteExpr
- LtExpr
- NeqExpr
- NotInExpr
- NotLikeExpr
- OrExpr
- PaginateExpr
- SortExpr
Above was listed the available query expressions, next you can see the use of expressions using the ExprBuilder and the ExprQueue.
BetweenExpr
The BetweenExpr can be used to query a value that is in an interval of values.
EqExpr
The EqExpr can be used to query a value using the equality operator.
GteExpr
The GteExpr can be used to query a value using that must be greater than or equal to one.
GtExpr
The GtExpr can be used to query a value using that must be greater than one.
InExpr
The InExpr can be used to query a value that can be equal to one, two or three.
LikeExpr
The LikeExpr can be used to query a value that must be equal (in the end only) "%value" where the % operator is a joker like the SQL commands.
LteExpr
The LteExpr can be used to query a value using that must be less than or equal to one.
LtExpr
The LtExpr can be used to query a value using that must be less than one.
NeqExpr
The NeqExpr can be used to query a value using the not equal operator.
NotInExpr
The NotInExpr can be used to query a value that must be different of one, two or three.
NotLikeExpr
The NotLikeExpr can be used to query a value that must be different (in the end only) "%value" where the % operator is a joker like the SQL commands.
OrExpr
The OrExpr can be used to query a value joining the above comparison expressions to perform the query. In the following example all fields that are filled with the value one or two will be returned.
PaginateExpr
The PaginateExpr can be used to paginate the results, the first parameter is the current page number and the second parameter is the limit of results per page.
SortExpr
The SortExpr can be used to sort the results, the first parameter is the field that will be sorted and the second parameter is the direction (can be used the asc and desc like in the SQL commands).
Parser
The parser can be used to parse an input data in different formats to the ExprBuilder. Currently are available three parser classes that implements the ParserInterface.
- ArrayParser
- RequestParser
- StringParser
ArrayParser
The ArrayParser can be used to parse the array data to ExprBuilder, see the example in the below:
RequestParser
The RequestParser can be used to parse an input data that is an instance of RequestInterface (compatible with PSR-7), see the example in the below:
StringParser
The StringParser can be used to parse an input data that is a string, see the example in the below:
Contributing
- Give me a star =)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Make your changes
- Run the tests, adding new ones for your own code if necessary (
vendor/bin/phpunit
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request