1. Go to this page and download the library: Download earc/query-language 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/ */
earc / query-language example snippets
use eArc\QueryLanguage\AbstractResolver;
class MyResolver extends AbstractResolver
{
public function findAll(string $dataCategory) : iterable
{
// ...
}
protected function queryRelation(string $dataCategory, string $dataProperty, string $cmp, $value, ?iterable $allowedDataIdentifiers = null) : iterable
{
// ...
}
public function sort(string $dataCategory, string $sort, iterable $dataPropertyNames, ?iterable $dataIdentifiers, ?iterable $allowedDataIdentifiers = null, int $limit = 0, int $offset = 0) : iterable
{
// ... You may skip this and throw an exception if you do not want to sort your results via query.
}
}
use eArc\QueryLanguage\AbstractQueryFactory;
use eArc\QueryLanguage\Interfaces\ResolverInterface;
class MyFinder extends AbstractQueryFactory
{
protected function getQueryResolver() : ResolverInterface
{
// ...
}
}
$qFactory = new MyFinder();
$result = $qFactory->findBy('SomeCategory', []);