Skip to content

Instantly share code, notes, and snippets.

@zluiten
Created July 16, 2012 09:16
Show Gist options
  • Save zluiten/d5cd6d0b0ac28e722dd7 to your computer and use it in GitHub Desktop.
Save zluiten/d5cd6d0b0ac28e722dd7 to your computer and use it in GitHub Desktop.
paginator
<?php
$em = $this->getCursusService()->em();
$paginator = new \Zend\Paginator\Paginator(
new \DoctrineORMModule\Paginator\Adapter(
new \Doctrine\ORM\Tools\Pagination\Paginator(
$em->createQuery('SELECT c.id, c.number, SIZE(c.applications) AS applications, SIZE(c.days) AS days FROM Application\\Entity\\Course c')->setHydrationMode(3)
)
)
);
$paginator->setCurrentPageNumber(1);
var_dump($paginator->count());
@zluiten
Copy link
Author

zluiten commented Jul 16, 2012

#0 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Exec/SingleSelectExecutor.php(38): Doctrine\ORM\Tools\Pagination\CountOutputWalker->walkSelectStatement(Object(Doctrine\ORM\Query\AST\SelectStatement))
#1 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php(241): Doctrine\ORM\Query\Exec\SingleSelectExecutor->__construct(Object(Doctrine\ORM\Query\AST\SelectStatement), Object(Doctrine\ORM\Tools\Pagination\CountOutputWalker))
#2 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php(341): Doctrine\ORM\Query\SqlWalker->getExecutor(Object(Doctrine\ORM\Query\AST\SelectStatement))
#3 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(233): Doctrine\ORM\Query\Parser->parse()
#4 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(245): Doctrine\ORM\Query->_parse()
#5 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(737): Doctrine\ORM\Query->_doExecute()
#6 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(562): Doctrine\ORM\AbstractQuery->execute(NULL, 3)
#7 /home/zluiten/dev/cmapp/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Pagination/Paginator.php(144): Doctrine\ORM\AbstractQuery->getScalarResult()
#8 /home/zluiten/dev/cmapp/vendor/doctrine/doctrine-orm-module/src/DoctrineORMModule/Paginator/Adapter.php(86): Doctrine\ORM\Tools\Pagination\Paginator->count()
#9 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/Paginator/Paginator.php(982): DoctrineORMModule\Paginator\Adapter->count()
#10 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/Paginator/Paginator.php(443): Zend\Paginator\Paginator->_calculatePageCount()
#11 /home/zluiten/dev/cmapp/module/CmCursus/src/CmCursus/Controller/CmCursusController.php(94): Zend\Paginator\Paginator->count()
#12 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php(150): CmCursus\Controller\CmCursusController->index2Action()
#13 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent))
#14 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#15 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#18 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#19 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#20 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#21 /home/zluiten/dev/cmapp/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(317): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#22 /home/zluiten/dev/cmapp/public/index.php(49): Zend\Mvc\Application->run()
#23 {main}

@benjamingb
Copy link

I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment