Skip to content

Instantly share code, notes, and snippets.

@greg606
Created January 31, 2016 16:48
Show Gist options
  • Save greg606/c786877405e7b04b6f25 to your computer and use it in GitHub Desktop.
Save greg606/c786877405e7b04b6f25 to your computer and use it in GitHub Desktop.
/**
* get total records
*
* @return integer
*/
public function getTotalRecords()
{
$qb = clone $this->queryBuilder;
$this->_addSearch($qb);
$qb->resetDQLPart('orderBy');
$gb = $qb->getDQLPart('groupBy');
if (empty($gb) || !in_array($this->fields['_identifier_'], $gb))
{
$qb->select(" count({$this->fields['_identifier_']}), (:postcode) distance ");
return $qb->getQuery()->getSingleResult()[1];
}
else
{
$qb->resetDQLPart('groupBy');
$qb->select(" count(distinct {$this->fields['_identifier_']}) ");
return $qb->getQuery()->getSingleScalarResult();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment