Builds a sql source by prepending the table to the join if join is given.
@param Sql\Table $table
@param Sql\Join $join
@param Sql\JoinType $joinType
@param Sql\Condition $joinCondition
@return Sql\Source
15488
private function BuildSource(Sql\Table $table, Sql\Join $join = null, Sql\JoinType $joinType = null, Sql\Condition $joinCondition = null)
    {
        $src = $table;
        if ($join)
        {
            if (!$joinType || !$joinCondition)
                throw new \InvalidArgumentException("If join is given, a join type and join condition are also required.");
            
            $src = $join->Join($table, $joinType, $joinCondition, true);
        }
        return $src;
    }
154619
protected function compileOneJoin(Join $join, array &$bindings): string
    {
        $sql = $join->type.' JOIN '.$this->compileIdentifierWithAlias($join->table, $join->tableAlias, $bindings);

        if ($join->criteria) {
            $sql .= ' ON '.$this->compileCriteria($join->criteria, $bindings);
        }

        return $sql;
    }
212627
public function join($type = null, $table = null, array $joinOn = null): Select
    {
        if (!\is_string($type) || !\preg_match('/left|right|inner|full/i', $type)) {
            throw new InvalidArgumentException('$type has to be left|right|inner|full');
        }
        if (!\is_string($table) && !\is_array($table)) {
            throw new InvalidArgumentException('$table has to be an array or a string');
        }
        if (!\is_array($joinOn)) {
            throw new InvalidArgumentException('$on has to be an array');
        }

        $this->join[] = \sprintf(
            ' %s JOIN %s ON %s',
            \strtoupper($type),
            \implode(', ', $this->namesClass->parse($table, true)),
            (new Condition($this->namesClass->getAliases()))->parse($joinOn)
        );

        return $this;
    }
1240519
function InnerJoin(Table $table, Condition $condition, $prepend = false)
    {
        return $this->Join($table, JoinType::Inner(), $condition, $prepend);
    }
480806
public function join(array $join = [], $table = '')
    {
        $string = '';

        foreach ($join as $type => $value) {
            $string .= sprintf("%s %s ON %s.%s = %s.%s", $type, $value[0], $value[0], $value[1], $table, $value[2]);
        }

        return $string;
    }
1147614
public function rightJoin($table, $where, $using = true)
    {
        return $this->join('RIGHT', $table, $where, $using);
    }
576433
final public function join($table,$column,$operator=null,$value=null, $scape_quote=false) {
      $this->clauseJoin($table,$column,$operator,$value,$scape_quote,"");
      return $this;
   }
1159394
public function leftJoinUsing($table, $where)
    {
        $where = func_get_args();
        $table = array_shift($where);

        $this->join[] = [self::LEFT, $table, $where, true];

        return $this;
    }
669888
protected function _hasJoin_sql($key, $table, $cond, &$filter, &$options) {
		$relConf = $this->fieldConf[$key]['belongs-to-one'];
		$relModel = is_array($relConf)?$relConf[0]:$relConf;
		$rel = $this->getRelInstance($relModel,null,$key);
		$fkey = is_array($this->fieldConf[$key]['belongs-to-one']) ?
			$this->fieldConf[$key]['belongs-to-one'][1] : $rel->primary;
		$alias = $table.'__'.$key;
		$query = $this->_sql_left_join($key,$this->table,$fkey,[$table,$alias]);
		$this->_sql_mergeRelCondition($cond,$alias,$filter,$options);
		return $query;
	}
870709
protected function compileJoins(Builder $query, $joins)
    {
        $sql = array();

        $query->setBindings(array(), 'join');

        foreach ($joins as $join) {
            $table = $this->wrapTable($join->table);

            $clauses = array();

            foreach ($join->clauses as $clause) {
                $clauses[] = $this->compileJoinConstraint($clause);
            }

            foreach ($join->bindings as $binding) {
                $query->addBinding($binding, 'join');
            }

            $clauses[0] = $this->removeLeadingBoolean($clauses[0]);

            $clauses = implode(' ', $clauses);

            $type = $join->type;

            //
            $sql[] = "$type join $table on $clauses";
        }

        return implode(' ', $sql);
    }
42745
public function innerJoin($table, $alias_or_cond, $cond = null) {
		if (is_null($cond))
			$this->joins[] = new JoinClause(JoinClause::INNER_JOIN, $table, null, $alias_or_cond);
		else
			$this->joins[] = new JoinClause(JoinClause::INNER_JOIN, $table, $alias_or_cond, $cond);
		return $this;
	}
929205
protected function getJoinCriteriaUsingPreviousTable(int $joinIndex, string $table, string $column): string
    {
        $joinCriteria      = '';
        $previousJoinIndex = $joinIndex - 1;

        $join = $this->builder->getJoin();
        if (array_key_exists($previousJoinIndex, $join)) {
            // 上一个join存在
            $previousTable = $join[$previousJoinIndex]['table'];
            if ($join[$previousJoinIndex]['alias'] !== null) {
                $previousTable = $join[$previousJoinIndex]['alias'];
            }
        } elseif ($this->isSelect()) {
            // 查询
            $previousTable = $this->getFrom();
            $alias         = $this->getFromAlias();
            if (!empty($alias)) {
                $previousTable = $alias;
            }
        } elseif ($this->isUpdate()) {
            // 更新
            $previousTable = $this->getUpdate();
        } else {
            $previousTable = false;
        }

        // 上一个inner关联存在
        if ($previousTable && strpos($column, '.') === false) {
            $joinCriteria .= $previousTable . '.';
        }

        $joinCriteria .= $column . ' ' . QueryBuilder::OPERATOR_EQ . ' ' . $table . '.' . $column;
        return $joinCriteria;
    }
1298260
protected function makeConditions($type, $join = 'AND')
    {
        $conditionHolder = "{$type}Conditions";

        // If there are no clauses, return empty string
        if (count($this->$conditionHolder) === 0) {
            return '';
        }

        $conditions = [];

        /*
         * Bind all values to property to execute query
         */
        foreach ($this->$conditionHolder as $condition) {
            $conditions[] = $condition[0];
            $this->bindings = array_merge($this->bindings, $condition[1]);
        }

        return strtoupper($type).' '.implode(" $join ", $conditions);
    }
235641
public function buildJoinCondition(Criteria $c)
    {
        $joinCondition = null;
        for ($i = 0; $i < $this->count; $i++) {
            $criterion = $c->getNewCriterion($this->getLeftColumn($i), $this->getLeftColumn($i) . $this->getOperator($i) . $this->getRightColumn($i), Criteria::CUSTOM);
            if (null === $joinCondition) {
                $joinCondition = $criterion;
            } else {
                $joinCondition = $joinCondition->addAnd($criterion);
            }
        }
        $this->joinCondition = $joinCondition;
    }
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;
    }
354890
public function fullOuterJoin($table, $alias_or_cond, $cond = null) {
		if (is_null($cond))
			$this->joins[] = new JoinClause(JoinClause::FULL_OUTER_JOIN, $table, null, $alias_or_cond);
		else
			$this->joins[] = new JoinClause(JoinClause::FULL_OUTER_JOIN, $table, $alias_or_cond, $cond);
		return $this;
	}
785431
public function join($join, $condition = null, $type = 'LEFT') {
        $this->joins[] = ['join' => $join,
                          'condition' => $condition,
                          'type' => $type];
        return $this;
    }