[Fusionforge-commits] r10249 - trunk/src/common/include

Roland Mas lolando at libremir.placard.fr.eu.org
Fri Jul 16 10:16:06 CEST 2010


Author: lolando
Date: 2010-07-16 10:16:05 +0200 (Fri, 16 Jul 2010)
New Revision: 10249

Modified:
   trunk/src/common/include/database-pgsql.php
Log:
Added mechanics to delay the establishing of the DB connection until a query actually happens

Modified: trunk/src/common/include/database-pgsql.php
===================================================================
--- trunk/src/common/include/database-pgsql.php	2010-07-16 08:15:48 UTC (rev 10248)
+++ trunk/src/common/include/database-pgsql.php	2010-07-16 08:16:05 UTC (rev 10249)
@@ -97,6 +97,16 @@
 }
 
 /**
+ *  db_connect_if_needed() - Set up the DB connection if it's unset
+ */
+function db_connect_if_needed () {
+        global $gfconn ;
+        if (!isset ($gfconn)) {
+                db_connect () ;
+        }
+}
+
+/**
  *  db_query() - Query the database.
  *
  *  @deprecated since 4.8. Use db_query_params() instead!
@@ -108,6 +118,7 @@
  *	@return int result set handle.
  */
 function db_query($qstring,$limit='-1',$offset=0,$dbserver=SYS_DB_PRIMARY) {
+	db_connect_if_needed () ;
 	global $QUERY_COUNT;
 	$QUERY_COUNT++;
 
@@ -141,6 +152,7 @@
  *  @return int result set handle.
  */
 function db_query_from_file($file,$limit='-1',$offset=0,$dbserver=SYS_DB_PRIMARY) {
+	db_connect_if_needed () ;
 	global $QUERY_COUNT;
 	$QUERY_COUNT++;
 
@@ -178,6 +190,7 @@
  *	@return int result set handle.
  */
 function db_query_params($qstring,$params,$limit='-1',$offset=0,$dbserver=SYS_DB_PRIMARY) {
+	db_connect_if_needed () ;
 	global $QUERY_COUNT;
 	$QUERY_COUNT++;
 




More information about the Fusionforge-commits mailing list