protected function prepareTotalCount()
{
if (!$this->query instanceof Query) {
throw new InvalidConfigException('The "query" property must be an instance "' . Query::className() . '" or its subclasses.');
}
if (!empty($this->query->showMeta)) {
$meta = $this->getMeta();
if (isset($meta['total_found'])) {
return (int) $meta['total_found'];
}
if (isset($meta['total'])) {
return (int) $meta['total'];
}
}
$query = clone $this->query;
return (int) $query->limit(-1)->offset(-1)->orderBy([])->facets([])->showMeta(false)->count('*', $this->db);
}