mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 17:05:37 +02:00
BUGFIX Allow omitting FROM clause in sqlQueryToString()
This commit is contained in:
parent
f7fd2d46da
commit
2e1dc517e6
@ -1010,14 +1010,13 @@ class SQLite3Database extends SS_Database {
|
|||||||
* Convert a SQLQuery object into a SQL statement
|
* Convert a SQLQuery object into a SQL statement
|
||||||
*/
|
*/
|
||||||
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
public function sqlQueryToString(SQLQuery $sqlQuery) {
|
||||||
if (!$sqlQuery->from) return '';
|
|
||||||
$distinct = $sqlQuery->distinct ? "DISTINCT " : "";
|
$distinct = $sqlQuery->distinct ? "DISTINCT " : "";
|
||||||
if($sqlQuery->delete) {
|
if($sqlQuery->delete) {
|
||||||
$text = "DELETE ";
|
$text = "DELETE ";
|
||||||
} else if($sqlQuery->select) {
|
} else if($sqlQuery->select) {
|
||||||
$text = "SELECT $distinct" . implode(", ", $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->where) $text .= " WHERE (" . $sqlQuery->getFilter(). ")";
|
||||||
if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby);
|
if($sqlQuery->groupby) $text .= " GROUP BY " . implode(", ", $sqlQuery->groupby);
|
||||||
|
Loading…
Reference in New Issue
Block a user