Skip to content

Commit

Permalink
Merge pull request #150 from mulcek/patch-2
Browse files Browse the repository at this point in the history
DBALQueryBuilderSubscriber orderBy query part is removed at count query
  • Loading branch information
l3pp4rd authored Dec 6, 2016
2 parents 6cedcd4 + 1ff05ba commit c91dddb
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ public function items(ItemsEvent $event)
/** @var $target QueryBuilder */
$target = $event->target;

// get the query
$sql = $target->getSQL();

// count results
$qb = clone $target;

//reset count orderBy since it can break query and slow it down
$qb
->resetQueryPart('orderBy')
;

// get the query
$sql = $qb->getSQL();

$qb
->resetQueryParts()
->select('count(*) as cnt')
Expand Down Expand Up @@ -60,4 +66,4 @@ public static function getSubscribedEvents()
'knp_pager.items' => array('items', 10 /*make sure to transform before any further modifications*/)
);
}
}
}

0 comments on commit c91dddb

Please sign in to comment.