function PagerPluginBase::executeCountQuery

Same name and namespace in other branches
  1. 9 core/modules/views/src/Plugin/views/pager/PagerPluginBase.php \Drupal\views\Plugin\views\pager\PagerPluginBase::executeCountQuery()
  2. 10 core/modules/views/src/Plugin/views/pager/PagerPluginBase.php \Drupal\views\Plugin\views\pager\PagerPluginBase::executeCountQuery()
  3. 11.x core/modules/views/src/Plugin/views/pager/PagerPluginBase.php \Drupal\views\Plugin\views\pager\PagerPluginBase::executeCountQuery()

Execute the count query, which will be done just prior to the query itself being executed.

1 method overrides PagerPluginBase::executeCountQuery()
None::executeCountQuery in core/modules/views/src/Plugin/views/pager/None.php
Execute the count query, which will be done just prior to the query itself being executed.

File

core/modules/views/src/Plugin/views/pager/PagerPluginBase.php, line 154

Class

PagerPluginBase
Base class for views pager plugins.

Namespace

Drupal\views\Plugin\views\pager

Code

public function executeCountQuery(&$count_query) {
    $this->total_items = $count_query->execute()
        ->fetchField();
    if (!empty($this->options['offset'])) {
        $this->total_items -= $this->options['offset'];
    }
    // Prevent from being negative.
    $this->total_items = max(0, $this->total_items);
    return $this->total_items;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.