function Select::addJoin

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::addJoin()
  2. 10 core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::addJoin()
  3. 11.x core/lib/Drupal/Core/Database/Query/Select.php \Drupal\Core\Database\Query\Select::addJoin()

Overrides SelectInterface::addJoin

4 calls to Select::addJoin()
Select::innerJoin in core/lib/Drupal/Core/Database/Query/Select.php
Inner Join against another table in the database.
Select::join in core/lib/Drupal/Core/Database/Query/Select.php
Default Join against another table in the database.
Select::leftJoin in core/lib/Drupal/Core/Database/Query/Select.php
Left Outer Join against another table in the database.
Select::__construct in core/lib/Drupal/Core/Database/Query/Select.php
Constructs a Select object.

File

core/lib/Drupal/Core/Database/Query/Select.php, line 633

Class

Select
Query builder for SELECT statements.

Namespace

Drupal\Core\Database\Query

Code

public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []) {
    if (empty($alias)) {
        if ($table instanceof SelectInterface) {
            $alias = 'subquery';
        }
        else {
            $alias = $table;
        }
    }
    $alias_candidate = $alias;
    $count = 2;
    while (!empty($this->tables[$alias_candidate])) {
        $alias_candidate = $alias . '_' . $count++;
    }
    $alias = $alias_candidate;
    if (is_string($condition)) {
        $condition = str_replace('%alias', $alias, $condition);
    }
    $this->tables[$alias] = [
        'join type' => $type,
        'table' => $table,
        'alias' => $alias,
        'condition' => $condition,
        'arguments' => $arguments,
    ];
    return $alias;
}

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