1. Go to this page and download the library: Download rugolinifr/enhanced-find-by 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/ */
rugolinifr / enhanced-find-by example snippets
$finder = (new \Rugolinifr\EnhancedFindBy\Factory\EnhancedFindByFactory())
->createEnhancedFindBy($entityManager);
// fetches every `Person` entity
$entities = $finder->findBy(Person::class);
// fetches every newborn `Person` entity using the "greater than" operator
$newborns = $finder->findBy(Person::class, ['birth >' => new \DateTimeImmutable('yesterday')]);
// fetches every newborn girl `Person`
$newborns = $finder->findBy(
Person::class,
[
'birth >' => new \DateTimeImmutable('yesterday'),
'sex =' => GenderEnum::GIRL,
],
);
// fetches every extra-European `Person` entity with implicit joins on two other entities
$extraEuropeans = $finder->findBy(Person::class, ['address.country.continent !=' => 'Europe']);
// fetches every `Person` entity having long black hair from a Doctrine embeddable
$blackHairedPersons = $finder->findBy(
Person::class,
[
'hair->length >' => 20,
'hair->color =' => 'black', // Use arrow ("->") notation to filter against a Doctrine embeddable
],
);
// fetches every Person having a description starting with "Once upon a time"
$finder->findBy(Person::class, ['description like' => 'Once upon a time%']);
dql
SELECT e0
FROM Person e0
JOIN e0.address e1
JOIN e1.country e2
WHERE e0.name LIKE 'John%'
AND e0.birth < '2010-01-01'
AND e0.eyeColor != 'blue'
AND e2.continent = 'Europe'