Skip to content
This repository
Browse code

MINOR Return empty string from SQLQuery->sql() if SELECT is the defau…

…lt value, and no FROM is set (moved logic from DB-specific implementations)
  • Loading branch information...
commit 1704e42d5188cd4a2940250e12d1374d70ba6169 1 parent 01f5b3d
Ingo Schommer authored May 19, 2011

Showing 1 changed file with 4 additions and 0 deletions. Show diff stats Hide diff stats

  1. 4  core/model/SQLQuery.php
4  core/model/SQLQuery.php
@@ -378,6 +378,10 @@ function getFilter() {
378 378
 	 * @return string
379 379
 	 */
380 380
 	function sql() {
  381
+		// Don't process empty queries
  382
+		$select = is_array($this->select) ? $this->select[0] : $this->select;
  383
+		if($select == '*' && !$this->from) return '';
  384
+		
381 385
 		$sql = DB::getConn()->sqlQueryToString($this);
382 386
 		if($this->replacementsOld) $sql = str_replace($this->replacementsOld, $this->replacementsNew, $sql);
383 387
 		return $sql;

0 notes on commit 1704e42

Please sign in to comment.
Something went wrong with that request. Please try again.