Quotes both the table and alias for an array of joins as stored in a Query
object

@param array $joins The joins to quote.
@return array
500752
protected function _quoteJoins($joins)
    {
        $result = [];
        foreach ($joins as $value) {
            $alias = null;
            if (!empty($value['alias'])) {
                $alias = $this->_driver->quoteIdentifier($value['alias']);
                $value['alias'] = $alias;
            }

            if (is_string($value['table'])) {
                $value['table'] = $this->_driver->quoteIdentifier($value['table']);
            }

            $result[$alias] = $value;
        }

        return $result;
    }
950590
private function buildJoins()
    {
        $joins = array();

        foreach ($this->query['joins'] as $join) {
            // Handle join with alias
            if (is_array($join[0])) {
                $joins[] = "LEFT JOIN `{$join[0][0]}` `{$join[0][1]}` on {$join[1]}";
            }
            // Handle regular joining
            else {
                $joins[] = "LEFT JOIN `{$join[0]}` on {$join[1]}";
            }
        }

        return implode(" ", $joins);
    }
496220
public function getAnswer(array $queries): array
    {
        $answer = [];
        foreach ($queries as $query) {
            $answer = array_merge($answer, $this->getRecordsRecursively($query));
        }

        return $answer;
    }
1187708
protected function compileJoins(Builder $query, $joins)
    {
        return collect($joins)->map(function ($join) use ($query) {
            $table = $this->wrapTable($join->table);

            return trim("{$join->type} join {$table} {$this->compileWheres($join)}");
        })->implode(' ');
    }
1232132
public function fromToSql(?JoinClauseStrategy $join = null, bool $useClause = true): array
    {
        $params = [];

        $sql = [];

        foreach ($this->from as $from) {
            $from = $this->prepareFrom($from);

            $sqlPart = $from['table'];

            $from['alias'] && $sqlPart .= ' AS ' . $from['alias'];

            $params = array_merge($params, $from['params']);

            if ($join) {
                list($joinSql, $joinParams) = $join->joinToSql($from['tableKey']);

                if ($joinSql) {
                    $sqlPart .= ' ' . $joinSql;

                    $params = array_merge($params, $joinParams);
                }
            }

            $sql[] = $sqlPart;
        }

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

        if ($sql and $useClause) {
            $sql = 'FROM ' . $sql;
        }

        return [$sql, $params];
    }
954272
public function joins(array $joins, $context) {
		$result = null;

		foreach ($joins as $key => $join) {
			if ($result) {
				$result .= ' ';
			}
			$join = is_array($join) ? $this->_instance('query', $join) : $join;
			$options['keys'] = ['mode', 'source', 'alias', 'constraints'];
			$result .= $this->renderCommand('join', $join->export($this, $options));
		}
		return $result;
	}
771134
public static function getJoinRelationship(Join $join): string
    {
        @trigger_error(sprintf('The use of "%s::getJoinRelationship()" is deprecated since 2.3 and will be removed in 3.0. Use "%s::getJoin()" directly instead.', __CLASS__, Join::class), E_USER_DEPRECATED);

        return $join->getJoin();
    }
664837
protected function parseJoin($join)
    {
        $result = implode(' ', $join);
        foreach($join as $item)
        {
            $this->params = array_merge($this->params, $item->getBinds());
        }
        return $result;
    }
542526
private function visitQueries(array $queries)
    {
        $result = [];
        foreach ($queries as $query) {
            $result[] = $this->getInterpreter($query)->visit($query);
        }

        return $result;
    }
567532
protected function translateCriteria(array $filter, array &$joins)
    {
        list($column, $type) = $this->join(explode('.', $filter['column']), $joins);

        switch (true) {
            case is_array($filter['value']):
                $values = [];

                foreach ($filter['value'] as $value) {
                    $values[] = $this->adapter->getDriver()->quote($value, $type);
                }

                $comparison = ' IN (' . implode(', ', $values) . ')';
                break;

            case is_null($filter['value']):
                $comparison = ' IS NULL';
                break;

            default:
                $comparison = ' = ' . $this->adapter->getDriver()->quote($filter['value'], $type);
        }

        return $column . $comparison;
    }
75901
public function from($tables): SelectStatement
    {
        $subquery = new Subquery();
        $this->addExpression('subquery', $subquery);
        return $subquery->from($tables);
    }
826221
public function from($tables, $alias=null) {
		$this->tables = [];
		if(is_string($tables))
			return $this->addFrom($tables);
		else
			return $this->addFrom([$alias => $tables]);
	}
370969
protected function buildJoin($statements)
    {
        $sql = '';

        if (!array_key_exists('joins', $statements) || !is_array($statements['joins'])) {
            return $sql;
        }

        foreach ($statements['joins'] as $joinArr) {
            if (is_array($joinArr['table'])) {
                $mainTable = $joinArr['table'][0];
                $aliasTable = $joinArr['table'][1];
                $table = $this->wrapSanitizer($mainTable) . ' AS ' . $this->wrapSanitizer($aliasTable);
            } else {
                $table = $joinArr['table'] instanceof Raw ?
                    (string) $joinArr['table'] :
                    $this->wrapSanitizer($joinArr['table']);
            }
            $joinBuilder = $joinArr['joinBuilder'];

            $sqlArr = array(
                $sql,
                strtoupper($joinArr['type']),
                'JOIN',
                $table,
                'ON',
                $joinBuilder->getQuery('criteriaOnly', false)->getSql()
            );

            $sql = $this->concatenateQuery($sqlArr);
        }

        return $sql;
    }
648529
public function table($table, $alias = null)
    {
        if ($alias) {
            $table = [$alias => $table];
        } elseif (!is_array($table)) {
            $table = [$table];
        }

        $this->joins = [];
        foreach ($table as $alias => $name) {
            if ($name instanceof QueryInterface) {
                $expression = '(' . $name->getQuery() . ')';
            } else {
                $expression = $this->connection->quoteIdentifier($name);
            }
            if (is_string($alias)) {
                $this->tables[$alias] = $expression . ' ' . $alias;
            } else {
                $this->tables[$name] = $expression;
            }
        }

        return $this;
    }
680124
public function join($join = [])
    {
        $this->string['join'] = $this->useBuilder('join')->join($join, $this->getBase()->getTable());
        return $this;
    }
1071554
public function quoteByFields(array $identifiers): array
    {
        foreach ($identifiers as $key => $identifier) {
            if ($identifier instanceof RawExp) {
                $identifiers[$key] = $identifier->getValue();
                continue;
            }
            // table.id ASC
            if (preg_match('/^([\w-\.]+)(\s)*(.*)$/', $identifier, $match)) {
                $identifiers[$key] = $this->quoteName($match[1]) . $match[2] . $match[3];
                continue;
            }
            $identifiers[$key] = $this->quoteName($identifier);
        }

        return $identifiers;
    }
45232
public function from($tables)
    {
        if (is_string($tables)) {
            $tables = $this->splitParts($tables);
        }
        foreach ($tables as $k => $table) {
            if ($alias = $this->matchAlias($table)) {
                $tables[$k] = $this->db->quoteTable($alias[0]) . ' AS ' . $this->db->quoteTable($alias[1]);
            } else {
                $tables[$k] = $this->db->quoteTable($table);
            }
        }

        $this->query['from'] = implode(', ', $tables);

        return $this;
    }