make count behave like in SQL

also fixed count behavior according to limit and offset.
fixes #1458
This commit is contained in:
Carsten Brandt
2013-12-18 17:22:04 +01:00
parent 617de8ac55
commit b4612637ec
5 changed files with 39 additions and 23 deletions

View File

@ -283,13 +283,7 @@ class Query extends Component implements QueryInterface
$options = [];
$options['search_type'] = 'count';
$count = $this->createCommand($db)->search($options)['hits']['total'];
if ($this->limit === null && $this->offset === null) {
return $count;
} elseif ($this->offset !== null) {
$count = $this->offset < $count ? $count - $this->offset : 0;
}
return $this->limit === null ? $count : ($this->limit > $count ? $count : $this->limit);
return $this->createCommand($db)->search($options)['hits']['total'];
}
/**