function Sql::setCountField

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::setCountField()
  2. 8.9.x core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::setCountField()
  3. 10 core/modules/views/src/Plugin/views/query/Sql.php \Drupal\views\Plugin\views\query\Sql::setCountField()

Set what field the query will count() on for paging.

File

core/modules/views/src/Plugin/views/query/Sql.php, line 281

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

public function setCountField($table, $field, $alias = NULL) {
    if (empty($alias)) {
        $alias = $table . '_' . $field;
    }
    $this->count_field = [
        'table' => $table,
        'field' => $field,
        'alias' => $alias,
        'count' => TRUE,
    ];
}

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