mirror of
https://github.com/silverstripe/silverstripe-mssql
synced 2024-10-22 06:05:53 +00:00
BUGFIX Allow omitting FROM clause in sqlQueryToString()
This commit is contained in:
parent
6f5de764d2
commit
b772956ce8
@ -1186,8 +1186,6 @@ class MSSQLDatabase extends SS_Database {
|
||||
* Convert a SQLQuery object into a SQL statement.
|
||||
*/
|
||||
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
||||
if (!$sqlQuery->from) return '';
|
||||
|
||||
if($sqlQuery->orderby && strtoupper(trim($sqlQuery->orderby)) == 'RAND()') $sqlQuery->orderby = "NEWID()";
|
||||
|
||||
//Get the limit and offset
|
||||
@ -1250,7 +1248,7 @@ class MSSQLDatabase extends SS_Database {
|
||||
$text .= implode(", ", $sqlQuery->select);
|
||||
}
|
||||
|
||||
$text .= " FROM " . implode(" ", $sqlQuery->from);
|
||||
if($sqlQuery->from) $text .= " FROM " . implode(" ", $sqlQuery->from);
|
||||
if($sqlQuery->where) $text .= " WHERE (" . $sqlQuery->getFilter(). ")";
|
||||
if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby);
|
||||
if($sqlQuery->having) $text .= " HAVING ( " . implode(" ) AND ( ", $sqlQuery->having) . " )";
|
||||
|
Loading…
x
Reference in New Issue
Block a user