Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUGFIX Allow omitting FROM clause in sqlQueryToString()

  • Loading branch information...
commit cfe0066a3bd52cfe10f50bbcc0fa38f9e82479dd 1 parent a2d334c
@chillu chillu authored
Showing with 1 addition and 3 deletions.
  1. +1 −3 model/Database.php
View
4 model/Database.php
@@ -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) . " )";
Please sign in to comment.
Something went wrong with that request. Please try again.