1. Go to this page and download the library: Download cekurte/rql library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cekurte / rql example snippets
use Cekurte\Resource\Query\Language\Expr\EqExpr;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Processor\DoctrineOrmProcessor;
// ...
$qb = $yourDoctrineEntityRepository->createQueryBuilder('alias');
$queue = new ExprQueue();
$queue->enqueue(new EqExpr('alias.field', 'value'));
// You can enqueue all expressions that implemented
// the Cekurte\Resource\Query\Language\Contract\ExprInterface
(new DoctrineOrmProcessor($qb))->process($queue);
// And now you can use the Doctrine QueryBuilder normally
$results = $qb->getQuery()->getResult();
// ...
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\Processor\DoctrineOrmProcessor;
// ...
$qb = $yourDoctrineEntityRepository->createQueryBuilder('alias');
$builder = new ExprBuilder();
$builder->eq('field', 'value');
(new DoctrineOrmProcessor($qb))->process($builder);
// And now you can use the Doctrine QueryBuilder normally
$results = $qb->getQuery()->getResult();
// ...
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\BetweenExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->between('field', 1, 10);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new BetweenExpr('field', 1, 10));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\EqExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->eq('field', 'value');
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new EqExpr('field', 'value'));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\GteExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->gte('field', 1);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new GteExpr('field', 1));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\GtExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->gt('field', 1);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new GtExpr('field', 1));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\InExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->in('field', [1, 2, 3]);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new InExpr('field', [1, 2, 3]));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\LikeExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->like('field', '%value');
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new LikeExpr('field', '%value'));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\LteExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->lte('field', 1);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new LteExpr('field', 1));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\LtExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->lt('field', 1);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new LtExpr('field', 1));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\NeqExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->neq('field', 'value');
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new NeqExpr('field', 'value'));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\NotInExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->notin('field', [1, 2, 3]);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new NotInExpr('field', [1, 2, 3]));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\NotLikeExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->notlike('field', '%value');
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new NotLikeExpr('field', '%value'));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\OrExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->orx(['field:eq:1', 'field:eq:2']);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new OrExpr(['field:eq:1', 'field:eq:2']));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\PaginateExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->paginate(1, 10);
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new PaginateExpr(1, 10));
use Cekurte\Resource\Query\Language\ExprBuilder;
use Cekurte\Resource\Query\Language\ExprQueue;
use Cekurte\Resource\Query\Language\Expr\SortExpr;
// Using the ExprBuilder
$expr = new ExprBuilder();
$expr->sort('field', 'asc');
// OR using the ExprQueue...
$expr = new ExprQueue();
$expr->enqueue(new SortExpr('field', 'asc'));
use Cekurte\Resource\Query\Language\Parser\RequestParser;
// Suppose that your URI of the request is:
// http://www.yourdomain.com/?q[]=field:eq:1&q[]=field:eq:2
$parser = new RequestParser(
$yourRequestObjectThatImplementsPSR7RequestInterface
);
// If you need customize the query string parameter key that will
// be used, then you can set the parameter key using the following
// method (key "q" is default)
// $parser->setQueryStringParameter('expr');
/**
* @var $exprBuilder Cekurte\Resource\Query\Language\ExprBuilder
*/
$exprBuilder = $parser->parse();
use Cekurte\Resource\Query\Language\Parser\StringParser;
$data = ''
. 'field:eq:1&'
. 'field:eq:2&'
. 'field:eq:3'
;
$parser = new StringParser($data);
// If you need customize the expression separator parameter key that will
// be used, then you can set the parameter key using the following
// method (key "&" is default)
// $parser->setSeparator('SEPARATOR');
/**
* @var $exprBuilder Cekurte\Resource\Query\Language\ExprBuilder
*/
$exprBuilder = $parser->parse();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.