W3cubDocs

/Drupal 8

protected function Query::finish

protected Query::finish()

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

Return value

\Drupal\Core\Entity\Query\Sql\Query Returns the called object.

File

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

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], isset($field[2]) ? $field[2] : NULL);
  }
  return $this;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Query!Sql!Query.php/function/Query::finish/8.1.x