设置表关联(right)
@param $join mixed 要关联的表
@param mixed $on 关联条件
@return $this
354371
public function rightJoin($join, $on = null): TableCached
    {
        $this->statement->join('right', $join, $on);
        return $this;
    }
351843
public function innerJoinOnTo($source, $table, $on)
    {
        $this->join('INNER', $source, $table, $on);

        return $this;
    }
1243625
public function join($joinType, $tableName = '', $on = [], $alias = '')
    {
        if (is_string($joinType) && empty($tableName)) {
            $this->sqlParts['join'][] = $this->getAdapter()->quoteSql($joinType);
        } elseif ($tableName instanceof self) {
            $this->sqlParts['join'][] = $this->sqlJoin($joinType, $tableName, $on, $alias);
        } else {
            $this->sqlParts['join'][$tableName] = $this->sqlJoin($joinType, $tableName, $on, $alias);

            $this->_joinAlias[$tableName] = $alias;
        }

        return $this;
    }
11351
public function join($foreign, $on, $joinType = Joins::INNER)
    {
        $builder = $this->getJoinStatement()->getBuilder();
        $foreign = is_array($foreign) ? $foreign : [$foreign];
        $foreign[0] = !($foreign[0] instanceof Expression) ? new Table($foreign[0]) : $foreign[0];
        
        $foreign = $builder->completeExpression(...$foreign);
        
        if (is_array($on)) {
            $whereOn = new Statement\Where($builder);
            $on = count($on) === count($on, true) ? [$on] : $on;
            
            foreach ($on as $criteria) {
                list($criteria[0], $criteria[1]) = [
                    ($criteria[0] instanceof Expression) ? $criteria[0] : $builder->createColumn($criteria[0]),
                    ($criteria[1] instanceof Expression) ? $criteria[1] : $builder->createColumn($criteria[1]),
                ];
                $whereOn->where(...$criteria);
            }
            
            $on = $whereOn;
        }
        
        $this->addJoin($foreign, $on, $joinType);
        
        return $this;
    }
680124
public function join($join = [])
    {
        $this->string['join'] = $this->useBuilder('join')->join($join, $this->getBase()->getTable());
        return $this;
    }
573268
public function addJoinObject(Join $join)
    {
        if (!in_array($join, $this->joins)) { // compare equality, NOT identity
            $this->joins[] = $join;
        }

        return $this;
    }
590047
public function rightJoinOn($table, $where)
    {
        $where = func_get_args();
        $table = array_shift($where);

        $this->join[] = [self::RIGHT, $table, $where, false];

        return $this;
    }
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;
    }
244869
public function joinSubquery($subquery, $on, $joinType = Joins::INNER)
    {
        return $this->join($subquery, $on, $joinType);
    }
1290358
public function join(Clause\Join $clause)
    {
        if (is_array($clause)) {
            $this->join = array_merge($this->join[], array_values($clause));
        } else {
            $this->join[] = $clause;
        }

        return $this;
    }
1301072
public function join(string $to, string $as, string $on, $onParams = null, string $type = ''): self
    {
        return $this->push('join', sprintf('%sJOIN %s AS %s ON (%s)',
            $type ? strtoupper($type) .' ' : '',
            $this->prepareField($to),
            $this->agent->quoteField($as),
            $this->agent->prepareIdentifier($on, $onParams))
        );
    }
1110389
private function prepareJoin(array $join)
    {
        if ($join['table'] instanceof SelectQuery) {
            [$sql, $params] = $join['table']->toSql();

            $join['table'] = '(' . $sql . ')';

            $join['params'] = $params;
        }

        if ($join['on'] instanceof Conditions) {
            [$sql, $params] = $join['on']->toSql();

            $join['on'] = $sql;

            $join['params'] = array_merge($join['params'], $params);
        }

        return $join;
    }
365354
public function join($table, $on, $tablePrefix = null)
    {
        is_null($tablePrefix) && $tablePrefix = $this->tablePrefix;

        $this->table($table, $tablePrefix);
        $hasAlias = is_array($table) ? true : false;

        $tableName = $tablePrefix . ($hasAlias ? key($table) : $table);
        $this->join[count($this->table) - 1 . '_' . $tableName] = is_array($on) ? $this->parseOn($table, $on) : addslashes($on);
        return $this;
    }
1258041
protected function parseJoin($join, $options = [])
    {
        $joinStr = '';
        if (!empty($join)) {
            foreach ($join as $item) {
                list($table, $type, $on) = $item;
                $condition = [];
                foreach ((array)$on as $val) {
                    if (strpos($val, '=')) {
                        list($val1, $val2) = explode('=', $val, 2);
                        $condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options);
                    } else {
                        $condition[] = $val;
                    }
                }

                $table   = $this->parseTable($table, $options);
                $joinStr .= ' ' . $type . ' JOIN ' . $table . ' ON ' . implode(' AND ', $condition);
            }
        }
        return $joinStr;
    }
525766
public function on($relation): Statement
    {
        if (count($this->ons) >= count($this->joins)) {
            trigger_error('关联时,关联关系过多', E_USER_ERROR);
        }
        $this->ons[] = $relation;
        return $this;
    }
327422
public function inner($table, ...$on) {
        $this->join($table, Condition::cleanField($on[0]) . '=' . Condition::cleanField($on[1]), self::INNER);

        return $this;
    }
712422
public function innerJoinOn($table, $on)
    {
        $instance = $this->joinStrategyInstance();

        $instance->joinStrategy()->innerJoinOn($table, $on);

        return $instance;
    }