MINOR Return empty string from SQLQuery->sql() if SELECT is the default value, and no FROM is set (moved logic from DB-specific implementations)

This commit is contained in:
Ingo Schommer 2011-05-19 14:34:01 +12:00
parent 01f5b3d212
commit 1704e42d51

View File

@ -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;