Created
January 31, 2016 16:48
-
-
Save greg606/c786877405e7b04b6f25 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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