function Query::finish

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query::finish()
  2. 10 core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query::finish()
  3. 11.x core/lib/Drupal/Core/Entity/Query/Sql/Query.php \Drupal\Core\Entity\Query\Sql\Query::finish()

Finish the query by adding fields, GROUP BY and range.

Return value

$this Returns the called object.

1 call to Query::finish()
QueryAggregate::finish in core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
Overrides \Drupal\Core\Entity\Query\Sql\Query::finish().
1 method overrides Query::finish()
QueryAggregate::finish in core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
Overrides \Drupal\Core\Entity\Query\Sql\Query::finish().

File

core/lib/Drupal/Core/Entity/Query/Sql/Query.php, line 245

Class

Query
The SQL storage entity query class.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function finish() {
    $this->initializePager();
    if ($this->range) {
        $this->sqlQuery
            ->range($this->range['start'], $this->range['length']);
    }
    foreach ($this->sqlGroupBy as $field) {
        $this->sqlQuery
            ->groupBy($field);
    }
    foreach ($this->sqlFields as $field) {
        $this->sqlQuery
            ->addField($field[0], $field[1], $field[2] ?? NULL);
    }
    return $this;
}

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