You are here

protected function Tables::addNextBaseTable in Drupal 10

Same name in this branch
  1. 10 core/modules/workspaces/src/EntityQuery/Tables.php \Drupal\workspaces\EntityQuery\Tables::addNextBaseTable()
  2. 10 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()
  2. 9 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.

File

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

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);
}