Create a manyToMany join.

@param string $table
@param string $alias
@param mix    $condition
966469
private function setManyToManyJoin($table, $alias, $condition = null)
    {
        if (!in_array($alias, $this->tables)) {
            if ($condition) {
                $this->queryBuilder->join($table, $alias, 'WITH', $condition);
            } else {
                $this->queryBuilder->join($table, $alias);
            }
            $this->tables[] = $alias;
        }
    }
907580
public function leftJoin(string $tableName, string $tableAlias, string $condition) : self
    {
        $this->joins['left'][] = ['tableName' => $tableName, 'tableAlias' => $tableAlias, 'condition' => $condition];

        return $this;
    }
1114151
public function addFrom($table, $alias = null)
    {
        if ($alias) {
            $this->_tables[$alias] = $table;
        } else {
            $this->_tables[] = $table;
        }

        return $this;
    }
226115
public function join($type, $table, $condition)
    {
        settype($condition, 'array');

        //The table needle
        $needle = $this->_adapter->getTableNeedle();

        if (strpos($table, $needle) !== 0) {
            $table = $needle.$table;
        }

        $this->join[] = array(
            'type'      => strtoupper($type),
            'table'     => $table,
            'condition' => $condition,
        );

        return $this;
    }
764209
function LeftJoin(Table $table, Condition $condition, $prepend = false)
    {
        return $this->Join($table, JoinType::Left(), $condition, $prepend);
    }
1120335
public function from($table, string $alias = null): self
    {
        return $this->table($table, $alias);
    }
247441
public function belongsToMany($alias, $class, $junction, $foreignKey = null, $relatedKey = null, Closure $conditions = null) {
        $relation = (new ManyToMany($alias, $class))
            ->setJunction($junction)
            ->setPrimaryForeignKey($foreignKey)
            ->setRelatedForeignKey($relatedKey);

        if ($conditions) {
            $relation->setConditions($conditions);
        }

        return $this->addRelation($relation);
    }
787089
public function from($table, $alias = null)
    {
        if ($alias === null) {
            $this->from[] = $this->grammar->buildId($table);
        } else {
            $this->from[] = $this->grammar->buildIdWithAlias($table, $alias);
        }

        return $this;
    }
930555
public function join($trueTableName, $alias, $on) {
        $join = new Join($trueTableName, $alias, $on);

        $this->statementContext->getJoinClause()->addJoin($join);
        return $this;
    }
893868
public function Join(string $table, string $as, string $by, string $condition): QueryBuilder
    {
        $this->join[] = [
            'table' => $table,
            'as' => $as,
            'by' => $by,
            'cond' => $condition
        ];
        
        return $this;
    }
1280766
public function table(string $table, string $alias = null): self
    {
        $this->table['table'] = $this->getTableNameByClassName($table);
        $this->table['alias'] = $alias;

        return $this;
    }
60748
public function rightJoin($table, $condition = null, $alias = null)
    {
        return $this->join($table, $condition, $alias, 'RIGHT');
    }
1322460
public function alias(string $alias, ?string $table = null): IQueryBuilderHandler
    {
        if ($table === null && isset($this->statements['tables'][0]) === true) {
            $table = $this->statements['tables'][0];
        } else {
            $table = $this->tablePrefix . $table;
        }

        $this->statements['aliases'][$table] = \strtolower($alias);

        return $this;
    }
1082964
protected function anyJoin($type, $table, $conditions = '', $params = array())
    {
        $this->mergeParams($params);
        if ($alias = $this->matchAlias($table)) {
            $table = $this->db->quoteTable($alias[0]) . ' AS ' . $this->db->quoteTable($alias[1]);
        } else {
            $table = $this->db->quoteTable($table);
        }
        $conditions = $this->buildConditions($conditions);
        if ('' !== $conditions) {
            $conditions = ' ON ' . $conditions;
        }

        if (isset($this->query['join']) && is_string($this->query['join'])) {
            $this->query['join'] = array($this->query['join']);
        }

        $this->query['join'][] = $type . ' ' . $table . ' ' . $conditions;

        return $this;
    }
379061
private function setLeftJoin($table, $field, $parentField, $alias, $parentAlias, $withWhere = false)
    {
        if (!in_array($alias, $this->tables)) {
            $condition = $this->getFullFieldName($field, $alias).' = '.$this->getFullFieldName($parentField, $parentAlias);
            $this->queryBuilder->leftJoin($table, $alias, 'WITH', $condition);
            if ($withWhere) {
                $this->queryBuilder->andWhere($condition);
            }
            $this->tables[] = $alias;
        }
    }
201443
public function rightJoin($table, $alias = null, $on = null)
    {
        return $this->join($table, $alias, $on, 'RIGHT JOIN');
    }
201869
public static function addJoinOnce(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $association, string $joinType = null, string $conditionType = null, string $condition = null, string $originAlias = null): string
    {
        $join = self::getExistingJoin($queryBuilder, $alias, $association, $originAlias);

        if (null !== $join) {
            return $join->getAlias();
        }

        $associationAlias = $queryNameGenerator->generateJoinAlias($association);
        $query = "$alias.$association";

        if (Join::LEFT_JOIN === $joinType || QueryChecker::hasLeftJoin($queryBuilder)) {
            $queryBuilder->leftJoin($query, $associationAlias, $conditionType, $condition);
        } else {
            $queryBuilder->innerJoin($query, $associationAlias, $conditionType, $condition);
        }

        return $associationAlias;
    }