如何在Symfony2.1.1中将PagerFanta的数组作为数组?
$adapter = new \Pagerfanta\Adapter\DoctrineORMAdapter($query);
$pager = new \Pagerfanta\Pagerfanta($adapter);
$pager->setMaxPerPage(45);
$data = $pager->getCurrentPageResults();
print_r($data);
ArrayIterator Object
(
[storage:ArrayIterator:private] => Array
(
[0] => Trucking\MainBundle\Entity\Sparcs Object
(
[id:Trucking\MainBundle\Entity\Sparcs:private] => 77940
[container:Trucking\MainBundle\Entity\Sparcs:private] => MEDUUUU
...
...
...
我希望得到getQuery->getArrayResult();
答案 0 :(得分:3)
我会做查询
$array = $query->getResult(Query::HYDRATE_ARRAY);
使用ArrayAdapter
$adapter = new ArrayAdapter($array);
$pagerfanta = new Pagerfanta($adapter);