Skip to content

Commit

Permalink
Avoid ordering when counting.
Browse files Browse the repository at this point in the history
This not only optimizes the query, but also avoid errors caused when
ordering by fields set in the WHERE clause, because count() overrides
them by default.
  • Loading branch information
bar committed Mar 29, 2014
1 parent 8e2998e commit d6c9026
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ORM/Query.php
Expand Up @@ -463,6 +463,7 @@ public function applyOptions(array $options) {
public function count() {
$query = clone $this;
$query->limit(null);
$query->order([], true);
$query->offset(null);
$query->mapReduce(null, null, true);
$query->formatResults(null, true);
Expand Down

0 comments on commit d6c9026

Please sign in to comment.