1 select.inc public SelectQuery::addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array())

Implements SelectQueryInterface::addJoin().

Overrides SelectQueryInterface::addJoin

File

core/includes/database/select.inc, line 1553

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