Skip to content

Commit

Permalink
BUGFIX Allow omitting FROM clause in sqlQueryToString()
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed May 18, 2011
1 parent a2d334c commit cfe0066
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions model/Database.php
Expand Up @@ -707,15 +707,13 @@ function alterationMessage($message,$type=""){
* 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) . " )";
Expand Down

0 comments on commit cfe0066

Please sign in to comment.