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:
parent
3cef0fdbfa
commit
705c33bc35
@ -140,6 +140,16 @@ class Paginator implements \Countable, \IteratorAggregate
|
|||||||
$countQuery->setFirstResult(null)->setMaxResults(null);
|
$countQuery->setFirstResult(null)->setMaxResults(null);
|
||||||
|
|
||||||
try {
|
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 = $countQuery->getScalarResult();
|
||||||
$data = array_map('current', $data);
|
$data = array_map('current', $data);
|
||||||
$this->count = array_sum($data);
|
$this->count = array_sum($data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user