Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Tables.php

function Tables::addJoin

Same name in this branch
  1. 11.1.x core/modules/workspaces/src/EntityQuery/Tables.php \Drupal\workspaces\EntityQuery\Tables::addJoin()

Adds a join to a given table.

Parameters

string $type: The join type.

string $table: The table to join to.

string $join_condition: The condition on which to join to.

string $langcode: The langcode used on the join.

string|null $delta: (optional) A delta which should be used as additional condition.

Return value

string Returns the alias of the joined table.

4 calls to Tables::addJoin()
Tables::addJoin in core/modules/workspaces/src/EntityQuery/Tables.php
Adds a join to a given table.
Tables::addJoin in core/modules/workspaces/src/EntityQuery/Tables.php
Adds a join to a given table.
Tables::ensureEntityTable in core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
Joins the entity table, if necessary, and returns the alias for it.
Tables::ensureFieldTable in core/lib/Drupal/Core/Entity/Query/Sql/Tables.php
Ensure the field table is joined if necessary.
1 method overrides Tables::addJoin()
Tables::addJoin in core/modules/workspaces/src/EntityQuery/Tables.php
Adds a join to a given table.

File

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

Class

Tables
Adds database tables and fields to the SQL entity query.

Namespace

Drupal\Core\Entity\Query\Sql

Code

protected function addJoin($type, $table, $join_condition, $langcode, $delta = NULL) {
    $arguments = [];
    if ($langcode) {
        $entity_type_id = $this->sqlQuery
            ->getMetaData('entity_type');
        $entity_type = $this->entityTypeManager
            ->getActiveDefinition($entity_type_id);
        // For a data table, get the entity language key from the entity type.
        // A dedicated field table has a hard-coded 'langcode' column.
        $langcode_key = $entity_type->getDataTable() == $table ? $entity_type->getKey('langcode') : 'langcode';
        $placeholder = ':langcode' . $this->sqlQuery
            ->nextPlaceholder();
        $join_condition .= ' AND [%alias].[' . $langcode_key . '] = ' . $placeholder;
        $arguments[$placeholder] = $langcode;
    }
    if (isset($delta)) {
        $placeholder = ':delta' . $this->sqlQuery
            ->nextPlaceholder();
        $join_condition .= ' AND [%alias].[delta] = ' . $placeholder;
        $arguments[$placeholder] = $delta;
    }
    return $this->sqlQuery
        ->addJoin($type, $table, NULL, $join_condition, $arguments);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal