1
0
mirror of synced 2025-01-31 04:21:44 +03:00

Fixed counting exception

Fixed "Invalid parameter number: number of bound variables does not match number of tokens " exception during execution count on Query where select part of query contains :parameters.
This commit is contained in:
Merixstudio 2014-11-20 15:28:12 +01:00 committed by Marco Pivetta
parent bf5003f25e
commit 42aff75108

View File

@ -140,6 +140,16 @@ class Paginator implements \Countable, \IteratorAggregate
$countQuery->setFirstResult(null)->setMaxResults(null);
try {
$parser = new Query\Parser($countQuery);
$parameterMappings = $parser->parse($parser)->getParameterMappings();
$parameters = $countQuery->getParameters();
foreach($parameters as $k=>$param){
if(!array_key_exists($param->getName(), $parameterMappings)){
$parameters->remove($k);
}
}
$countQuery->setParameters($parameters);
$data = $countQuery->getScalarResult();
$data = array_map('current', $data);
$this->count = array_sum($data);