1. Go to this page and download the library: Download adnanmula/criteria 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/ */
adnanmula / criteria example snippets
//Use the criteria class to build queries
$criteria = new Criteria(
10, //Offset
20, //Limit
new Sorting(
new Order(
new FilterField('name'),
OrderType::ASC,
),
new Order(
new FilterField('name'),
OrderType::DESC,
),
),
new AndFilterGroup(
FilterType::OR,
new Filter(new FilterField('id'), new StringFilterValue('id'), FilterOperator::EQUAL),
new Filter(new FilterField('field'), new StringArrayFilterValue('value1', 'value2', 'value3'), FilterOperator::IN),
...$moreFilters
),
new OrFilterGroup(
FilterType::AND,
new Filter(new FilterField('json_field'), new ArrayElementFilterValue('value'), FilterOperator::IN_ARRAY),
new Filter(new FilterField('amount'), new IntFilterValue(3), FilterOperator::LESS_OR_EQUAL),
),
...$moreFilterGroups,
);
//Example of repository
$builder = $this->connection->createQueryBuilder();
$query = $builder->select('a.fields')
->from('table', 'a');
(new DbalCriteriaAdapter($builder))->execute($criteria);
$result = $query->execute()->fetchAllAssociative();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.