PHP code example of mention / fast-doctrine-paginator
1. Go to this page and download the library: Download mention/fast-doctrine-paginator 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/ */
mention / fast-doctrine-paginator example snippets
php
$query = $entityManager->createQuery('
SELECT u.id, u.name
FROM Acme\\Entity\\Users u
WHERE u.id > :idCursor
ORDER BY u.id ASC
');
// Number of items per page
$query->setMaxResults(3);
$paginator = DoctrinePaginatorBuilder::fromQuery($query)
->setDiscriminators([
new PageDiscriminator('idCursor', 'getId'),
])
->build();
foreach ($paginator as $page) {
foreach ($page() as $user) {
// ...
}
$em->clear();
}
php
$query = $entityManager->createQuery('
SELECT u.id, u.name
FROM Users u
WHERE u.id > :idCursor
ORDER BY u.id ASC
');
// Max results per page
$query->setMaxResults(3);
$paginator = DoctrinePaginatorBuilder::fromQuery($query)
->setDiscriminators([
new PageDiscriminator('idCursor', 'getId'),
])
->build();
foreach ($paginator as $page) {
foreach ($page() as $result) {
// ...
}
$em->clear();
}
php
foreach ($paginator as $page) {
foreach ($page() as $result) {
// ...
}
$em->clear();
}