You are here

protected function Tables::addNextBaseTable in Drupal 9

Same name in this branch
  1. 9 core/modules/workspaces/src/EntityQuery/Tables.php \Drupal\workspaces\EntityQuery\Tables::addNextBaseTable()
  2. 9 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::addNextBaseTable()
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/Query/Sql/Tables.php \Drupal\Core\Entity\Query\Sql\Tables::addNextBaseTable()

Add the next entity base table.

For example, when building the SQL query for

condition('uid.entity.name', 'foo', 'CONTAINS');

this adds the users table.

Parameters

\Drupal\Core\Entity\EntityType $entity_type: The entity type being joined, in the above example, User.

string $table: This is the table being joined, in the above example, {users}.

string $sql_column: This is the SQL column in the existing table being joined to.

\Drupal\Core\Field\FieldStorageDefinitionInterface $field_storage: The field storage definition for the field referencing this column.

Return value

string The alias of the next entity table joined in.

2 calls to Tables::addNextBaseTable()
Tables::addField in core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
Adds a field to a database query.
Tables::addNextBaseTable in core/modules/workspaces/src/EntityQuery/Tables.php
Add the next entity base table.
1 method overrides Tables::addNextBaseTable()
Tables::addNextBaseTable in core/modules/workspaces/src/EntityQuery/Tables.php
Add the next entity base table.

File

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

Class

Tables
Adds tables and fields to the SQL entity query.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function addNextBaseTable(EntityType $entity_type, $table, $sql_column, FieldStorageDefinitionInterface $field_storage) {
  $join_condition = '[%alias].[' . $entity_type
    ->getKey('id') . "] = [{$table}].[{$sql_column}]";
  return $this->sqlQuery
    ->leftJoin($entity_type
    ->getBaseTable(), NULL, $join_condition);
}