Bluz\Db\Query\Select::getSql PHP Method

getSql() public method

public getSql ( ) : string
return string
    public function getSql()
    {
        $query = "SELECT " . implode(', ', $this->sqlParts['select']) . " FROM ";
        $fromClauses = [];
        // Loop through all FROM clauses
        foreach ($this->sqlParts['from'] as $from) {
            $fromClause = $from['table'] . ' ' . $from['alias'] . $this->getSQLForJoins($from['alias']);
            $fromClauses[$from['alias']] = $fromClause;
        }
        $query .= join(', ', $fromClauses) . ($this->sqlParts['where'] !== null ? " WHERE " . (string) $this->sqlParts['where'] : "") . ($this->sqlParts['groupBy'] ? " GROUP BY " . join(", ", $this->sqlParts['groupBy']) : "") . ($this->sqlParts['having'] !== null ? " HAVING " . (string) $this->sqlParts['having'] : "") . ($this->sqlParts['orderBy'] ? " ORDER BY " . join(", ", $this->sqlParts['orderBy']) : "") . ($this->limit ? " LIMIT " . $this->limit . " OFFSET " . $this->offset : "");
        return $query;
    }