我有问题,knp 分页器只能这样工作:
$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*/
);
为什么会这样?我不明白。
这是我的树枝电话:
<li>{{ knp_pagination_sortable(paginator, 'Oldest', 'a.id', {'direction': 'desc'}) }}</li>
问候迈克尔