From 1704e42d5188cd4a2940250e12d1374d70ba6169 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 19 May 2011 14:34:01 +1200 Subject: [PATCH] MINOR Return empty string from SQLQuery->sql() if SELECT is the default value, and no FROM is set (moved logic from DB-specific implementations) --- core/model/SQLQuery.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/model/SQLQuery.php b/core/model/SQLQuery.php index 06e08a230..075962433 100755 --- a/core/model/SQLQuery.php +++ b/core/model/SQLQuery.php @@ -378,6 +378,10 @@ class SQLQuery { * @return string */ function sql() { + // Don't process empty queries + $select = is_array($this->select) ? $this->select[0] : $this->select; + if($select == '*' && !$this->from) return ''; + $sql = DB::getConn()->sqlQueryToString($this); if($this->replacementsOld) $sql = str_replace($this->replacementsOld, $this->replacementsNew, $sql); return $sql;