function Query::getSqlField

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

Constructs a select expression for a given field and language.

Parameters

string $field: The name of the field being queried.

string $langcode: The language code of the field.

Return value

string An expression that will select the given field for the given language in a SELECT query, such as 'base_table.id'.

3 calls to Query::getSqlField()
Query::addSort in core/lib/Drupal/Core/Entity/Query/Sql/Query.php
Adds the sort to the build query.
QueryAggregate::addAggregate in core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
Adds the aggregations to the query.
QueryAggregate::addGroupBy in core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php
Adds the groupby values to the actual query.

File

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

Class

Query
The SQL storage entity query class.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function getSqlField($field, $langcode) {
    if (!isset($this->tables)) {
        $this->tables = $this->getTables($this->sqlQuery);
    }
    $base_property = "base_table.{$field}";
    if (isset($this->sqlFields[$base_property])) {
        return $base_property;
    }
    else {
        return $this->tables
            ->addField($field, 'LEFT', $langcode);
    }
}

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