1. Go to this page and download the library: Download complex-heart/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/ */
complex-heart / criteria example snippets
namespace ComplexHeart\Domain\Criteria;
// Match the users with status active and more than 7k followers and from Spain and France
$g1 = FilterGroup::create()
->addFilterEqual('status', 1)
->addFilterGreaterThan('followers', 7000)
->addFilterIn('country', ['es', 'fr']);
$criteria = Criteria::default()
->withFilterGroup($g1)
->withOrderBy('surname')
->withOrderType('asc')
->withPageLimit(25)
->withPageOffset(50);
$users = $repository->match($criteria);
// alternative, same as above
$criteria = Criteria::default()
->withFilterGroup(FilterGroup::create()
->addFilterEqual('status', 1)
->addFilterGreaterThan('followers', 7000)
->addFilterIn('country', ['es', 'fr']))
->withOrderBy('surname')
->withOrderType('asc')
->withPageLimit(25)
->withPageOffset(50);
// In SQL, we may have something like:
// WHERE status = 1 AND followers >= 700 AND country in ('es', 'fr')
$users = $repository->match($criteria);
// Match articles with given term in title, or in tagline, or in content.
$criteria = Criteria::default()
->withFilterGroup(FilterGroup::create()->addFilterContains('title', $term))
->withFilterGroup(FilterGroup::create()->addFilterContains('tagline', $term))
->withFilterGroup(FilterGroup::create()->addFilterContains('content', $term))
->withOrderBy('created_at')
->withOrderType(Order::TYPE_ASC)
->withPageNumber(3);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.