// Write the "FROM" portion of the query
if (!
empty($this->QBFrom
)) { $sql .= "\nFROM " .
$this->
_fromTables();
} // Write the "JOIN" portion of the query
if (!
empty($this->QBJoin
)) { $sql .= "\n" .
implode("\n",
$this->QBJoin
);
} $sql .=
$this->
compileWhereHaving('QBWhere'
) .
$this->
compileGroupBy() .
$this->
compileWhereHaving('QBHaving'
) .
$this->
compileOrderBy(); // ORDER BY
// LIMIT
if ($this->QBLimit
) { $sql =
$this->
_limit($sql . "\n"
);
} return $this->
unionInjection($sql);
}