[Fusionforge-commits] r12778 - in trunk/src: common/include common/search plugins/globalsearch/www www/project/stats www/softwaremap www/trove www/trove/include

Roland Mas lolando at fusionforge.org
Tue Mar 15 16:08:46 CET 2011


Author: lolando
Date: 2011-03-15 16:08:46 +0100 (Tue, 15 Mar 2011)
New Revision: 12778

Modified:
   trunk/src/common/include/database-pgsql.php
   trunk/src/common/search/SearchQuery.class.php
   trunk/src/plugins/globalsearch/www/index.php
   trunk/src/www/project/stats/project_stats_utils.php
   trunk/src/www/softwaremap/trove_list.php
   trunk/src/www/trove/TroveCategory.class.php
   trunk/src/www/trove/include/trove.php
Log:
Use symbolic names for database identifiers and keep the constants inside the abstraction layer

Modified: trunk/src/common/include/database-pgsql.php
===================================================================
--- trunk/src/common/include/database-pgsql.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/common/include/database-pgsql.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -312,7 +312,7 @@
 /**
  *	db_begin() - Begin a transaction.
  *
- *  @param		constant		Database server (SYS_DB_PRIMARY, SYS_DB_STATS, SYS_DB_TROVE, SYS_DB_SEARCH)
+ *  @param		constant		Database server ('DB_PRIMARY', 'DB_STATS', 'DB_TROVE', 'DB_SEARCH')
  *	@return true.
  */
 function db_begin($dbserver=NULL) {
@@ -331,7 +331,7 @@
 /**
  *	db_commit() - Commit a transaction.
  *
- *  @param		constant		Database server (SYS_DB_PRIMARY, SYS_DB_STATS, SYS_DB_TROVE, SYS_DB_SEARCH)
+ *  @param		constant		Database server ('DB_PRIMARY', 'DB_STATS', 'DB_TROVE', 'DB_SEARCH')
  *	@return true on success/false on failure.
  */
 function db_commit($dbserver=NULL) {
@@ -356,7 +356,7 @@
 /**
  *	db_rollback() - Rollback a transaction.
  *
- *  @param		constant		Database server (SYS_DB_PRIMARY, SYS_DB_STATS, SYS_DB_TROVE, SYS_DB_SEARCH)
+ *  @param		constant		Database server ('DB_PRIMARY', 'DB_STATS', 'DB_TROVE', 'DB_SEARCH')
  *	@return true on success/false on failure.
  */
 function db_rollback($dbserver=NULL) {
@@ -485,7 +485,7 @@
 /**
  *  db_error() - Returns the last error from the database.
  *
- *  @param		constant		Database server (SYS_DB_PRIMARY, SYS_DB_STATS, SYS_DB_TROVE, SYS_DB_SEARCH)
+ *  @param		constant		Database server ('DB_PRIMARY', 'DB_STATS', 'DB_TROVE', 'DB_SEARCH')
  *	@return text error message.
  */
 function db_error($dbserver=NULL) {

Modified: trunk/src/common/search/SearchQuery.class.php
===================================================================
--- trunk/src/common/search/SearchQuery.class.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/common/search/SearchQuery.class.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -186,7 +186,7 @@
 			$qpa,
 			$this->rowsPerPage + 1,
 			$this->offset,
-			SYS_DB_SEARCH
+			'DB_SEARCH'
 		);
 
 		$this->rowsTotalCount = db_numrows($this->result);

Modified: trunk/src/plugins/globalsearch/www/index.php
===================================================================
--- trunk/src/plugins/globalsearch/www/index.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/plugins/globalsearch/www/index.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -146,14 +146,14 @@
 
 $limit=25;
 
-$result = db_query_qpa ($qpa, $limit+1, $offset, SYS_DB_SEARCH);
+$result = db_query_qpa ($qpa, $limit+1, $offset, 'DB_SEARCH');
 $rows = $rows_returned = db_numrows($result);
 
 if (!$result || $rows < 1) {
         $no_rows = 1;
         echo "<h2>".sprintf (_('No matches found for %1$s'),
 			     $gwords)."</h2>";
-        echo db_error(SYS_DB_SEARCH);
+        echo db_error('DB_SEARCH');
 
 } else {
 

Modified: trunk/src/www/project/stats/project_stats_utils.php
===================================================================
--- trunk/src/www/project/stats/project_stats_utils.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/www/project/stats/project_stats_utils.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -58,12 +58,12 @@
 		WHERE group_id=$1 ORDER BY month DESC, day DESC";
 
 	if ($span == 30) {
-		$res = db_query_params($sql, array($group_id), 30, 0, SYS_DB_STATS);
+		$res = db_query_params($sql, array($group_id), 30, 0, 'DB_STATS');
 	} else {
-		$res = db_query_params($sql, array($group_id),  7, 0, SYS_DB_STATS);
+		$res = db_query_params($sql, array($group_id),  7, 0, 'DB_STATS');
 	}
 
-	echo db_error(SYS_DB_STATS);
+	echo db_error('DB_STATS');
 
    // if there are any days, we have valid data.
 	if ( ($valid_days = db_numrows( $res )) > 0 ) {
@@ -109,7 +109,7 @@
 
 	} else {
 		echo _('Project did not exist on this date.');
-		echo db_error(SYS_DB_STATS) .'</p>';
+		echo db_error('DB_STATS') .'</p>';
 	}
 
 }
@@ -121,7 +121,7 @@
 		SELECT * FROM stats_project_months 
 		WHERE group_id=$1
 		ORDER BY group_id DESC, month DESC
-	",array($group_id), -1, 0, SYS_DB_STATS);
+	",array($group_id), -1, 0, 'DB_STATS');
 
 	   // if there are any weeks, we have valid data.
 	if ( ($valid_months = db_numrows( $res )) > 1 ) {
@@ -168,7 +168,7 @@
 
 	} else {
 		echo _('Project did not exist on this date.')."<p>";
-		echo db_error(SYS_DB_STATS);
+		echo db_error('DB_STATS');
 	}
 }
 
@@ -178,7 +178,7 @@
 		SELECT *
 		FROM stats_project_all_vw
 		WHERE group_id=$1
-	", array($group_id), -1, 0, SYS_DB_STATS);
+	", array($group_id), -1, 0, 'DB_STATS');
 	$row = db_fetch_array($res);
 
 	?>

Modified: trunk/src/www/softwaremap/trove_list.php
===================================================================
--- trunk/src/www/softwaremap/trove_list.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/www/softwaremap/trove_list.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -235,9 +235,9 @@
 	$qpa = db_construct_qpa($qpa, ' WHERE trove_agg.trove_cat_id=$1', array($form_cat));
 	$qpa = db_join_qpa($qpa, $qpa_and) ;
 	$qpa = db_construct_qpa($qpa, ' ORDER BY trove_agg.trove_cat_id ASC, trove_agg.ranking ASC');
-	$res_grp = db_query_qpa($qpa, $TROVE_HARDQUERYLIMIT, 0, SYS_DB_TROVE);
+	$res_grp = db_query_qpa($qpa, $TROVE_HARDQUERYLIMIT, 0, 'DB_TROVE');
 
-	echo db_error(SYS_DB_TROVE);
+	echo db_error('DB_TROVE');
 	$querytotalcount = db_numrows($res_grp);
 
 	// #################################################################

Modified: trunk/src/www/trove/TroveCategory.class.php
===================================================================
--- trunk/src/www/trove/TroveCategory.class.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/www/trove/TroveCategory.class.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -62,7 +62,7 @@
 			if (!$dataArray || !is_array($dataArray)) {
 				if (!$this->fetchData($categoryId)) {
 					$this->setError(_('Invalid Trove Category'),
-							_('That Trove category does not exist.').' '.db_error(SYS_DB_TROVE)
+							_('That Trove category does not exist.').' '.db_error('DB_TROVE')
 					);
 				}
 			} else {
@@ -181,7 +181,7 @@
 				)
 				AND trove_cat.parent=$1
 				ORDER BY fullname",
-				array($this->categoryId), -1, 0, SYS_DB_TROVE);
+				array($this->categoryId), -1, 0, 'DB_TROVE');
 			
 			if(!$result) {
 				$this->setError();

Modified: trunk/src/www/trove/include/trove.php
===================================================================
--- trunk/src/www/trove/include/trove.php	2011-03-15 15:00:57 UTC (rev 12777)
+++ trunk/src/www/trove/include/trove.php	2011-03-15 15:08:46 UTC (rev 12778)
@@ -49,7 +49,7 @@
 			SELECT trove_cat_id,fullname
 			FROM trove_cat
 			WHERE parent=$1
-			AND trove_cat_id!=0;", array($mynode), -1, 0, SYS_DB_TROVE);
+			AND trove_cat_id!=0;", array($mynode), -1, 0, 'DB_TROVE');
 
 		while ($row_child = db_fetch_array($res_child)) {
 			trove_genfullpaths($row_child['trove_cat_id'],
@@ -78,7 +78,7 @@
 			SELECT trove_cat_id
 			FROM trove_cat
 			WHERE parent=$1
-			AND trove_cat_id!=0;", array($mynode), -1, 0, SYS_DB_TROVE);
+			AND trove_cat_id!=0;", array($mynode), -1, 0, 'DB_TROVE');
 
 		while ($row_child = db_fetch_array($res_child)) {
 			trove_updaterootparent($row_child['trove_cat_id'],$rootnode);
@@ -103,7 +103,7 @@
 	$res_verifycat = db_query_params("
 		SELECT trove_cat_id,fullpath_ids
 		FROM trove_cat
-		WHERE trove_cat_id=$1", array($trove_cat_id), -1, 0, SYS_DB_TROVE);
+		WHERE trove_cat_id=$1", array($trove_cat_id), -1, 0, 'DB_TROVE');
 
 	if (db_numrows($res_verifycat) != 1) return 1;
 	$row_verifycat = db_fetch_array($res_verifycat);




More information about the Fusionforge-commits mailing list