Get second table alias

@param  array $cls
@param  string $right right part of eq
@return string
@access protected
333091
protected function getSecondTableAlias(
        array $cls,
        /*# string */ $right
    )/*# : string */ {
        if (false !== strpos($right, '.')) {
            return '';
        } else {
            $alias = $cls[3];
            if (!is_string($alias)) {
                $alias = $cls[2];
            }
            return $alias . '.';
        }
    }
906321
protected function queryBetween($left, $right)
    {
        $sortableField = static::getSortableField();
        $query = static::applySortableGroup($this->newQuery(), $this);

        return $query->where($sortableField, '>', $left)->where($sortableField, '<', $right);
    }
1135889
public String alias(Object cls) {
        assertArgumentNotNull("cls", cls);
        assertCanBeClassification(cls);
        return findClassificationAlias((Classification) cls);
    }
404231
public function getTableAlias($table_name = null)
    {
        if (!$table_name) {
            $table_name = $this->getTableName();
        }
        $bits = explode("_", $table_name);
        $alias = '';
        foreach ($bits as $bit) {
            $alias .= strtolower(substr($bit, 0, 1));
        }
        return $alias;
    }
155048
public function alias($alias = null)
    {
        if (null === $alias) {
            $alias = $this->getTableAlias();
        }
        $this->oosql_table_alias = $alias;
        return $this;
    }
333681
public function table($table, /*# string */ $alias = '')
    {
        $tbl = $this->fixTable($table, $alias);
        $clone = [] === $this->tables ? $this : clone $this;
        $clone->tables = $tbl;
        return $clone;
    }
244137
public function alias($alias)
    {
        if (is_array($alias)) {
            foreach ($alias as $key => $val) {
                $this->options['alias'][$key] = $val;
            }
        } else {
            if (isset($this->options['table'])) {
                $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table'];
                if (false !== strpos($table, '__')) {
                    $table = $this->parseSqlTable($table);
                }
            } else {
                $table = $this->getTable();
            }

            $this->options['alias'][$table] = $alias;
        }
        return $this;
    }
1283727
private function getSQLForJoins($fromAlias, array &$knownAliases)
    {
        $sql = '';

        if (isset($this->sqlParts['join'][$fromAlias])) {
            foreach ($this->sqlParts['join'][$fromAlias] as $join) {
                if (array_key_exists($join['joinAlias'], $knownAliases)) {
                    throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases));
                }
                $sql                             .= ' ' . strtoupper($join['joinType'])
                    . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
                    . ' ON ' . ((string) $join['joinCondition']);
                $knownAliases[$join['joinAlias']] = true;
            }

            foreach ($this->sqlParts['join'][$fromAlias] as $join) {
                $sql .= $this->getSQLForJoins($join['joinAlias'], $knownAliases);
            }
        }

        return $sql;
    }
1007300
public function getTableForAlias($alias)
    {
        if (isset($this->aliases[$alias])) {
            return $this->aliases[$alias];
        }

        return null;
    }
1188041
public function rightJoinUsing($table, $where)
    {
        $where = func_get_args();
        $table = array_shift($where);

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

        return $this;
    }
1100932
public function andRightnodeEquals($rightnode, $alias = null)
    {
        list($alias, $suffix) = $this->getAliasAndSuffix($alias);

        return $this->andWhere($alias.'._rightnode = :rightnode'.$suffix)
                        ->setParameter('rightnode'.$suffix, $rightnode);
    }
1076520
public function getRightsFromNames(array $names)
    {
        $rights_string = '';
        foreach ($this->getRights() as $right => $value) {
            $rights_string .= in_array($right, $names) ? '1' : '0';
        }
        return strrev($rights_string);
    }
1264880
protected function correct_choices(array $right) {
        // Return appropriate string for single/multiple correct answer(s).
        if (count($right) == 1) {
                return get_string('correctansweris', 'qtype_multichoice',
                        implode(', ', $right));
        } else if (count($right) > 1) {
                return get_string('correctanswersare', 'qtype_multichoice',
                        implode(', ', $right));
        } else {
                return "";
        }
    }
590047
public function rightJoinOn($table, $where)
    {
        $where = func_get_args();
        $table = array_shift($where);

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

        return $this;
    }
1124998
public function getRightColumnName(bool $withTableName = false): string
    {
        return ($withTableName) ? $this->addTableName($this->rightColumnName) : $this->rightColumnName;
    }
1194283
public function getFirstTableAlias($table=null)
    {
        if (!$table) {
            $table = static::getQuery()->get('table');
        }
        if ($table) {
            if (is_array($table)) {
                return static::getFirstTableAlias(current($table));
            }
            
            $table = preg_split('/(\,|(left|right)\s+join)/', $table)[0]; 
            $table = preg_split('/\s+(as\s+)?/', $table);
            $table = isset($table[1]) && $table[1] ? $table[1] : static::buildRealTableName($table[0], false); // 如果没有alias需要使用全名
            $table = trim($table);
        }
        
        return $table;
    }
490523
private static function fixLeftAndRight($css) {
		$css = preg_replace(self::$patterns['left'], self::$patterns['tmpToken'], $css);
		$css = preg_replace(self::$patterns['right'], 'left', $css);
		$css = str_replace(self::$patterns['tmpToken'], 'right', $css);

		return $css;
	}