From 8849c8f6b9f17b66bfad01a945013df19aba95ab Mon Sep 17 00:00:00 2001 From: fBrignoli Date: Thu, 27 Oct 2011 16:27:05 +0000 Subject: [PATCH] [*] CO : Empty parameters are not added --- classes/db/DbQuery.php | 49 +++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/classes/db/DbQuery.php b/classes/db/DbQuery.php index bd2ed476c..499c12985 100644 --- a/classes/db/DbQuery.php +++ b/classes/db/DbQuery.php @@ -54,7 +54,8 @@ class DbQueryCore */ public function select($fields) { - $this->query['select'][] = $fields; + if (!empty($fields)) + $this->query['select'][] = $fields; return $this; } @@ -66,7 +67,8 @@ class DbQueryCore */ public function from($table) { - $this->query['from'] = _DB_PREFIX_.$table; + if (!empty($table)) + $this->query['from'] = _DB_PREFIX_.$table; return $this; } @@ -79,7 +81,9 @@ class DbQueryCore */ public function join($join) { - $this->query['join'][] = $join; + if (!empty($join)) + $this->query['join'][] = $join; + return $this; } @@ -91,7 +95,10 @@ class DbQueryCore */ public function leftJoin($join) { - return $this->join('LEFT JOIN '._DB_PREFIX_.$join); + if (!empty($join)) + return $this->join('LEFT JOIN '._DB_PREFIX_.$join); + + return $this; } /** @@ -102,7 +109,10 @@ class DbQueryCore */ public function innerJoin($join) { - return $this->join('INNER JOIN '._DB_PREFIX_.$join); + if (!empty($join)) + return $this->join('INNER JOIN '._DB_PREFIX_.$join); + + return $this; } /** @@ -112,7 +122,10 @@ class DbQueryCore */ public function leftOuterJoin($join) { - return $this->join('LEFT OUTER JOIN '._DB_PREFIX_.$join); + if (!empty($join)) + return $this->join('LEFT OUTER JOIN '._DB_PREFIX_.$join); + + return $this; } /** @@ -122,7 +135,10 @@ class DbQueryCore */ public function naturalJoin($join) { - return $this->join('NATURAL JOIN '._DB_PREFIX_.$join); + if (!empty($join)) + return $this->join('NATURAL JOIN '._DB_PREFIX_.$join); + + return $this; } /** @@ -133,7 +149,9 @@ class DbQueryCore */ public function where($restriction) { - $this->query['where'][] = $restriction; + if (!empty($restriction)) + $this->query['where'][] = $restriction; + return $this; } @@ -145,7 +163,9 @@ class DbQueryCore */ public function having($restriction) { - $this->query['having'][] = $restriction; + if (!empty($restriction)) + $this->query['having'][] = $restriction; + return $this; } @@ -157,7 +177,9 @@ class DbQueryCore */ public function orderBy($fields) { - $this->query['order'][] = $fields; + if (!empty($fields)) + $this->query['order'][] = $fields; + return $this; } @@ -169,7 +191,9 @@ class DbQueryCore */ public function groupBy($fields) { - $this->query['group'][] = $fields; + if (!empty($fields)) + $this->query['group'][] = $fields; + return $this; } @@ -233,4 +257,5 @@ class DbQueryCore { return $this->build(); } -} \ No newline at end of file +} +