Index: trunk/admin/install/inst_ado.php =================================================================== diff -u -N -r3901 -r7391 --- trunk/admin/install/inst_ado.php (.../inst_ado.php) (revision 3901) +++ trunk/admin/install/inst_ado.php (.../inst_ado.php) (revision 7391) @@ -1,23 +1,41 @@ 0 ) + /** + * Returns reference to database connection + * + * @param bool $new_type Return Kernel4 or in-portal connection object + * @return kDBConnection + */ + function &inst_GetADODBConnection($new_type = false) { - $DB = ADONewConnection($g_DBType); - $connected = $DB->Connect($g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName); - - $ADODB_CACHE_DIR = $pathtoroot.'cache'; - $ADODB_FETCH_MODE = 2; - $ADODB_COUNTRECS = false; - $DB->debug = false; - $DB->cacheSecs = 3600; + 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 ($new_type) { + static $new_db = null; + + if (!isset($new_db) && $g_DBType) { + require_once FULL_PATH.'/core/kernel/db/db_connection.php'; + $new_db = new kDBConnection($g_DBType); + $new_db->Connect($g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName); + } + + return $new_db; + } + + if( !isset($DB) && strlen($g_DBType) > 0 ) + { + $DB = ADONewConnection($g_DBType); + $connected = $DB->Connect($g_DBHost, $g_DBUser, $g_DBUserPassword, $g_DBName); + + $ADODB_CACHE_DIR = $pathtoroot.'cache'; + $ADODB_FETCH_MODE = 2; + $ADODB_COUNTRECS = false; + $DB->debug = false; + $DB->cacheSecs = 3600; + } + return $DB; } - return $DB; -} ?>