QQueryBuilder::GetStatement PHP Method

GetStatement() public method

public GetStatement ( )
    public function GetStatement()
    {
        // SELECT Clause
        if ($this->blnCountOnlyFlag) {
            if ($this->blnDistinctFlag) {
                $strSql = "SELECT\r\n    COUNT(*) AS q_row_count\r\n" . "FROM    (SELECT DISTINCT ";
                $strSql .= "    " . implode(",\r\n    ", $this->strSelectArray);
            } else {
                $strSql = "SELECT\r\n    COUNT(*) AS q_row_count\r\n";
            }
        } else {
            if ($this->blnDistinctFlag) {
                $strSql = "SELECT DISTINCT\r\n";
            } else {
                $strSql = "SELECT\r\n";
            }
            if ($this->strLimitInfo) {
                $strSql .= $this->objDatabase->SqlLimitVariablePrefix($this->strLimitInfo) . "\r\n";
            }
            $strSql .= "    " . implode(",\r\n    ", $this->strSelectArray);
        }
        // FROM and JOIN Clauses
        $strSql .= sprintf("\r\nFROM\r\n    %s\r\n    %s", implode(",\r\n    ", $this->strFromArray), implode("\r\n    ", $this->strJoinArray));
        // Custom "FROM" Columns
        if (count($this->strCustomFromArray)) {
            $strSql .= ",\r\n    " . implode(",\r\n    ", $this->strCustomFromArray);
        }
        // WHERE Clause
        if (count($this->strWhereArray)) {
            $strWhere = implode("\r\n    ", $this->strWhereArray);
            if (trim($strWhere) != '1=1') {
                $strSql .= "\r\nWHERE\r\n    " . $strWhere;
            }
        }
        // Additional Ordering/Grouping clauses
        if (count($this->strGroupByArray)) {
            $strSql .= "\r\nGROUP BY\r\n    " . implode(",\r\n    ", $this->strGroupByArray);
        }
        if (count($this->strOrderByArray)) {
            $strSql .= "\r\nORDER BY\r\n    " . implode(",\r\n    ", $this->strOrderByArray);
        }
        // Limit Suffix (if applicable)
        if ($this->strLimitInfo) {
            $strSql .= "\r\n" . $this->objDatabase->SqlLimitVariableSuffix($this->strLimitInfo);
        }
        // For Distinct Count Queries
        if ($this->blnCountOnlyFlag && $this->blnDistinctFlag) {
            $strSql .= "\r\n) as q_count_table";
        }
        return $strSql;
    }