function Sql::build

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

Builds the necessary info to execute the query.

Overrides QueryPluginBase::build

File

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

Class

Sql
Views query plugin for an SQL query.

Namespace

Drupal\views\Plugin\views\query

Code

public function build(ViewExecutable $view) {
    // Make the query distinct if the option was set.
    if (!empty($this->options['distinct'])) {
        $this->setDistinct(TRUE);
    }
    // Store the view in the object to be able to use it later.
    $this->view = $view;
    $view->initPager();
    // Let the pager modify the query to add limits.
    $view->pager
        ->query();
    $view->build_info['query'] = $this->query();
    $view->build_info['count_query'] = $this->query(TRUE);
}

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