Skip to content

Commit

Permalink
Fixed reference to registry to get EM
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ridgway committed Sep 15, 2010
1 parent 82f610a commit 4ecf152
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/ZendX/Doctrine2/Paginator.php
Expand Up @@ -47,7 +47,7 @@ public function count()
if (null === $this->_countQb) {
$this->_countQb = clone $this->_qb;
$from = $this->_countQb->getDqlPart('from');
$identifierNames = \Zend_Registry::get('doctrine')->getClassMetadata($from[0]->getFrom())->getIdentifierFieldNames();
$identifierNames = $this->_qb->getEntityManager()->getClassMetadata($from[0]->getFrom())->getIdentifierFieldNames();
$this->_countQb->select('count('.$this->_countQb->getRootAlias().'.' . $identifierNames[0] . ')');
}
return $this->_rowCount = $this->_countQb->getQuery()->getSingleScalarResult();
Expand All @@ -67,6 +67,11 @@ public function getItems($offset, $itemCountPerPage)
return $this->_qb->getQuery()->getResult();
}

/**
* Set a custom query builder to get the count
*
* @param Doctrine\ORM\QueryBuilder $qb
*/
public function setCountQueryBuilder(\Doctrine\ORM\QueryBuilder $qb)
{
$this->_countQb = $qb;
Expand Down

0 comments on commit 4ecf152

Please sign in to comment.