From cfe0066a3bd52cfe10f50bbcc0fa38f9e82479dd Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 19 May 2011 11:37:33 +1200 Subject: [PATCH] BUGFIX Allow omitting FROM clause in sqlQueryToString() --- model/Database.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/model/Database.php b/model/Database.php index 0d08f9ac1..b82887d7d 100755 --- a/model/Database.php +++ b/model/Database.php @@ -707,15 +707,13 @@ abstract class SS_Database { * Convert a SQLQuery object into a SQL statement */ public function sqlQueryToString(SQLQuery $sqlQuery) { - if (!$sqlQuery->from) return ''; $distinct = $sqlQuery->distinct ? "DISTINCT " : ""; if($sqlQuery->delete) { $text = "DELETE "; } else if($sqlQuery->select) { $text = "SELECT $distinct" . 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) . " )";