[Fusionforge-commits] r8509 - trunk/gforge/www/trove

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Dec 10 14:18:32 CET 2009


Author: lolando
Date: 2009-12-10 14:18:32 +0100 (Thu, 10 Dec 2009)
New Revision: 8509

Modified:
   trunk/gforge/www/trove/TroveCategory.class.php
Log:
db_query_qpa for TroveCategory.class.php

Modified: trunk/gforge/www/trove/TroveCategory.class.php
===================================================================
--- trunk/gforge/www/trove/TroveCategory.class.php	2009-12-10 13:18:17 UTC (rev 8508)
+++ trunk/gforge/www/trove/TroveCategory.class.php	2009-12-10 13:18:32 UTC (rev 8509)
@@ -49,8 +49,6 @@
 	var $parent;
 	
 	var $filter;
-	var $filterQueryAlias = '';
-	var $filterQueryAnd = '';
 	
 	/**
 	 *  Constructor.
@@ -218,27 +216,42 @@
 		return ($this->dataArray['subprojects'] ? $this->dataArray['subprojects'] : 0);
 	}
 	
-		function setFilter($filterArray) {
+	function setFilter($filterArray) {
 		$this->filter = $filterArray;
-		
-		for($i = 0, $count = sizeof($filterArray); $i < $count; $i++) {
-			$this->filterQueryAlias .= ', trove_agg trove_agg_'.$i.' ';
-			$this->filterQueryAnd .= 'AND trove_agg_'.$i.'.trove_cat_id='
-			.$filterArray[$i].' AND trove_agg_'.$i.'.group_id='
-			.'trove_agg.group_id ';
-		}
 	}
+
+	}
 	
 	function getProjects($offset) {
-		$result = db_query('
-			SELECT * 
-			FROM trove_agg, '.$this->filterQueryAlias.'
-			WHERE trove_agg.trove_cat_id='.$this->categoryId.' '.$this->filterQueryAnd.'
-			ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC
-			', TROVE__PROJECTS_PER_PAGE, '.$offset.', SYS_DB_TROVE);
+		$qpa = db_constract_qpa () ;
+		$qpa = db_construct_qpa ($qpa, 'SELECT * FROM trove_agg') ;
+		
+		for($i = 0, $count = sizeof($this->filter); $i < $count; $i++) {
+			$qpa = db_construct_qpa ($qpa,
+						 ", trove_agg trove_agg_$i") ;
+		}
+
+		$qpa = db_construct_qpa ($qpa,
+					 ' WHERE trove_agg.trove_cat_id=$1',
+					 array ($this->categoryId)) ;
+
+		for($i = 0, $count = sizeof($this->filter); $i < $count; $i++) {
+			$qpa = db_construct_qpa ($qpa,
+						 " AND trove_agg_$i.trove_cat_id=$1 AND trove_agg_$i.group_id=trove_agg.group_id",
+						 array ($this->filter[$i])) ;
+		}
+
+		$qpa = db_construct_qpa (' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC') ;
+		
+		$result = db_query_qpa ($qpa, TROVE__PROJECTS_PER_PAGE, $offset);
 		return $result;
 	}
 	
 }
 
+// Local Variables:
+// mode: php
+// c-file-style: "bsd"
+// End:
+
 ?>




More information about the Fusionforge-commits mailing list