PHP code example of kadudutra / doctrine-pagination
1. Go to this page and download the library: Download kadudutra/doctrine-pagination 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/ */
kadudutra / doctrine-pagination example snippets
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Task
*
* @ORM\Table(name="task")
* @ORM\Entity(repositoryClass="DoctrinePagination\ORM\PaginatedRepository")
*/
class Task
{
}
namespace Repository;
use DoctrinePagination\ORM\PaginatedQueryBuilder;
use DoctrinePagination\ORM\PaginatedRepository;
/**
* Class TaskRepository
*/
class TaskRepository extends PaginatedRepository
{
}
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class Task
*
* @ORM\Table(name="task")
* @ORM\Entity(repositoryClass="Repository\TaskRepository")
*/
class Task
{
}
protected function processCriteria(PaginatedQueryBuilder $qb, array $criteria)
{
foreach ($criteria as $field => $value) {
switch ($field) {
case 'description':
$qb->andWhere(...);
unset($criteria[$field]);
break;
}
}
parent::processCriteria($qb, $criteria);
}