function SelectQuery::addJoin

Overrides SelectQueryInterface::addJoin

5 calls to SelectQuery::addJoin()
SelectQuery::innerJoin in includes/database/select.inc
Inner Join against another table in the database.
SelectQuery::join in includes/database/select.inc
Default Join against another table in the database.
SelectQuery::leftJoin in includes/database/select.inc
Left Outer Join against another table in the database.
SelectQuery::rightJoin in includes/database/select.inc
Right Outer Join against another table in the database.
SelectQuery::__construct in includes/database/select.inc
Constructs a Query object.

File

includes/database/select.inc, line 1400

Class

SelectQuery
Query builder for SELECT statements.

Code

public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) {
    if (empty($alias)) {
        if ($table instanceof SelectQueryInterface) {
            $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] = array(
        '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.