/** * @inheritdoc */ protected function prepareTotalCount() { $origQuery = $this->query; $this->modifyQuery($this->query); $r = parent::prepareTotalCount(); $this->query = $origQuery; return $r; }
/** * @inheritdoc */ protected function prepareTotalCount() { $count = parent::prepareTotalCount(); if (!$this->query instanceof QueryInterface) { throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\\db\\Query or its subclasses.'); } $maxMatches = isset($this->query->options['max_matches']) ? $this->query->options['max_matches'] : 1000; // Default matches to sphinx $query = clone $this->query; $count = (int) $query->limit(-1)->offset(-1)->orderBy([])->count('*', $this->db); if ($count > $maxMatches) { $count = $maxMatches; } return $count; }