Index: trunk/globals.php
===================================================================
diff -u -r348 -r382
--- trunk/globals.php (.../globals.php) (revision 348)
+++ trunk/globals.php (.../globals.php) (revision 382)
@@ -86,38 +86,36 @@
function &GetADODBConnection()
{
- global $g_adodbConnection, $g_DBType, $g_DBHost,$g_DBUser,$g_DBUserPassword,$g_DBName,$g_DebugMode;
- global $ADODB_FETCH_MODE,$ADODB_COUNTRECS,$ADODB_CACHE_DIR,$pathtoroot;
- //echo '
'.print_r( debug_backtrace() , true).'
';
- if(!isset($g_adodbConnection) && strlen($g_DBType)>0)
- {
- $g_adodbConnection = ADONewConnection($g_DBType);
+ static $DB = null;
+
+ global $g_DBType, $g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName, $g_DebugMode;
+ global $ADODB_FETCH_MODE, $ADODB_COUNTRECS, $ADODB_CACHE_DIR, $pathtoroot;
+
+ if( !isset($DB) && strlen($g_DBType) > 0 )
+ {
+ $DB = ADONewConnection($g_DBType);
+ $connected = $DB->Connect($g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName);
+ if(!$connected) die("Error connecting to database $g_DBHost
\n");
- $connected = $g_adodbConnection->Connect($g_DBHost,$g_DBUser,$g_DBUserPassword,$g_DBName);
- if(!$connected)
- {
- echo "Error connecting to database $g_DBHost
\n";
- die();
- }
- $ADODB_CACHE_DIR = $pathtoroot."cache";
- $ADODB_FETCH_MODE = 2;
- $ADODB_COUNTRECS = FALSE;
- $g_adodbConnection->debug = defined('ADODB_OUTP') ? 1 : 0;
- $g_adodbConnection->cacheSecs = 3600;
- $g_adodbConnection->Execute('SET SQL_BIG_SELECTS=1');
- }
- elseif (!strlen($g_DBType)) {
- global $rootURL;
- echo "In-Portal is probably not installed, or configuration file is missing.
";
- echo "Please use the installation script to fix the problem.
";
- if (!preg_match('/admin/', $_SERVER['SCRIPT_FILENAME'])) {
- $ins = 'admin/';
- }
- echo "Go to installation script
";
- flush();
- die();
- }
- return $g_adodbConnection;
+ $ADODB_CACHE_DIR = $pathtoroot."cache";
+ $ADODB_FETCH_MODE = 2;
+ $ADODB_COUNTRECS = false;
+ $DB->debug = defined('ADODB_OUTP') ? 1 : 0;
+ $DB->cacheSecs = 3600;
+ $DB->Execute('SET SQL_BIG_SELECTS = 1');
+ }
+ elseif( !strlen($g_DBType) )
+ {
+ global $rootURL;
+ echo 'In-Portal is probably not installed, or configuration file is missing.
';
+ echo 'Please use the installation script to fix the problem.
';
+ if ( !preg_match('/admin/', $_SERVER['SCRIPT_FILENAME']) ) $ins = 'admin/';
+
+ echo 'Go to installation script
';
+ flush();
+ exit;
+ }
+ return $DB;
}
function GetNextResourceId($Increment=1)