/**
  * @inheritdoc
  */
 protected function prepareTotalCount()
 {
     if (!$this->query instanceof Query) {
         throw new SphinxException('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->connection);
 }
Example #2
0
 /**
  * @inheritdoc
  * @throws \yii\base\InvalidConfigException
  */
 public static function find()
 {
     return \Yii::createObject(Query::className(), [get_called_class()]);
 }