mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of Phraseanet
|
|
*
|
|
* (c) 2005-2014 Alchemy
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Alchemy\Phrasea\Model\Repositories;
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
|
|
/**
|
|
* LazaretFileRepository
|
|
*
|
|
* This class was generated by the Doctrine ORM. Add your own custom
|
|
* repository methods below.
|
|
*/
|
|
class LazaretFileRepository extends EntityRepository
|
|
{
|
|
|
|
public function findPerPage(array $base_ids, $offset = 0, $perPage = 10)
|
|
{
|
|
$base_ids = implode(', ', array_map(function ($int) {
|
|
return (int) $int;
|
|
}, $base_ids));
|
|
|
|
$dql = '
|
|
SELECT f
|
|
FROM Phraseanet:LazaretFile f'
|
|
. ('' === $base_ids ? '' : ' WHERE f.base_id IN (' . $base_ids . ')')
|
|
. ' ORDER BY f.id DESC';
|
|
|
|
$query = $this->_em->createQuery($dql);
|
|
$query->setFirstResult($offset)
|
|
->setMaxResults($perPage);
|
|
|
|
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query, true);
|
|
|
|
return $paginator;
|
|
}
|
|
}
|