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 11b409aac8
commit ced7d6db7a

View File

@ -378,6 +378,10 @@ class SQLQuery {
* @return string * @return string
*/ */
function sql() { 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); $sql = DB::getConn()->sqlQueryToString($this);
if($this->replacementsOld) $sql = str_replace($this->replacementsOld, $this->replacementsNew, $sql); if($this->replacementsOld) $sql = str_replace($this->replacementsOld, $this->replacementsNew, $sql);
return $sql; return $sql;