我的問題,是高棉民族分頁程序僅是這樣的:KNP分頁程序使用的findAll()方法
$em = $this->get('doctrine.orm.entity_manager');
$dql = "SELECT a FROM MainArtBundle:Art a";
$query = $em->createQuery($dql);
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$query,
$this->get('request')->query->get('page', 1) /*page number*/,
8 /*limit per page*/
);
但不能以這種方式:
$em = $this->getDoctrine()->getManager();
$entities = $em->getRepository('MainArtBundle:Art')->findAll();
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate(
$entities,
$this->get('request')->query->get('page', 1) /*page number*/,
/*limit per page*/
);
爲什麼會這樣呢?我不明白。
Here's我的樹枝電話:
<li>{{ knp_pagination_sortable(paginator, 'Oldest', 'a.id', {'direction': 'desc'}) }}</li>
問候邁克爾
IM漂亮多了。我不能直接分類我的實體,而不建立某種新的查詢。我的意思是我已經有我的查詢和實體用法我喜歡它,我只是想爲它添加分頁,並且文檔只顯示如何做到這一點..作爲你的問題演示..奇怪的是在我的情況它的涓涓細流到這個錯誤,這是非常錯誤的領導..我想把它添加到這個主題的搜索能力'嘗試調用類「Symfony \組件\ HttpFoundation \ JsonResponse」方法「getTemplate」。 (500內部服務器錯誤)' – blamb 2015-05-27 21:32:24
'in vendor/knplabs/knp-paginator-bundle/Twig/Extension/PaginationExtension.php at line 56''$ template?:$ pagination-> getTemplate(),' – blamb 2015-05-27 21:36:46