public function renderDefault()
{
$articles = $this->articlesDao->fetch(new ArticlesQuery());
$articles->applyPaginator($this['vp']->paginator);
$this->template->articles = $articles;
}
protected function createComponentVp()
{
return new VisualPaginator;
}
.
It automatically counts the query, passes the count of results to paginator
and then reads the offset from paginator and applies it to the query so you get the correct results.
Показать файл
Открыть проект
Примеры использования класса
Метод | Описание | |
---|---|---|
__construct ( Doctrine\ORM\AbstractQuery $query, |
||
applyPaginator ( Nette\Utils\Paginator $paginator, integer $itemsPerPage = NULL ) : |
||
applyPaging ( integer $offset, integer $limit ) : |
||
applySorting ( string | array $columns ) : |
||
clearSorting ( ) : |
Removes ORDER BY clause that is not inside subquery. | |
count ( ) : integer | ||
getFetchJoinCollection ( ) : boolean | ||
getIterator ( integer $hydrationMode = ORM\AbstractQuery::HYDRATE_OBJECT ) : ArrayIterator | ||
getTotalCount ( ) : integer | ||
getUseOutputWalkers ( ) : boolean | null | ||
isEmpty ( ) : boolean | ||
setFetchJoinCollection ( boolean $fetchJoinCollection ) : |
||
setUseOutputWalkers ( boolean | null $useOutputWalkers ) : |
||
toArray ( integer $hydrationMode = ORM\AbstractQuery::HYDRATE_OBJECT ) : array |
Метод | Описание | |
---|---|---|
createPaginatedQuery ( Doctrine\ORM\Query $query ) : Doctrine\ORM\Tools\Pagination\Paginator | ||
updating ( ) |
public __construct ( Doctrine\ORM\AbstractQuery $query, |
||
$query | Doctrine\ORM\AbstractQuery | |
$queryObject | ||
$repository | Kdyby\Persistence\Queryable |
public applyPaginator ( Nette\Utils\Paginator $paginator, integer $itemsPerPage = NULL ) : |
||
$paginator | Nette\Utils\Paginator | |
$itemsPerPage | integer | |
Результат |
public applyPaging ( integer $offset, integer $limit ) : |
||
$offset | integer | |
$limit | integer | |
Результат |
public applySorting ( string | array $columns ) : |
||
$columns | string | array | |
Результат |
public clearSorting ( ) : |
||
Результат |
public getFetchJoinCollection ( ) : boolean | ||
Результат | boolean |
public getIterator ( integer $hydrationMode = ORM\AbstractQuery::HYDRATE_OBJECT ) : ArrayIterator | ||
$hydrationMode | integer | |
Результат | ArrayIterator |
public getUseOutputWalkers ( ) : boolean | null | ||
Результат | boolean | null |
public setFetchJoinCollection ( boolean $fetchJoinCollection ) : |
||
$fetchJoinCollection | boolean | |
Результат |
public setUseOutputWalkers ( boolean | null $useOutputWalkers ) : |
||
$useOutputWalkers | boolean | null | |
Результат |