/** * Get a reference to the only instance of database class and connects to DB * * if the class has not been instantiated yet, this will also take * care of that * * @static * @return object Reference to the only instance of database class */ public static function instance() { if (self::$xoopsInstance !== false) { return self::$xoopsInstance; } $allowWebChanges = defined('XOOPS_DB_PROXY') ? false : true; if (substr(XOOPS_DB_TYPE, 0, 4) == 'pdo.') { self::$xoopsInstance = new icms_db_legacy_PdoDatabase(self::$pdoInstance, $allowWebChanges); } else { if (defined('XOOPS_DB_ALTERNATIVE') && class_exists(XOOPS_DB_ALTERNATIVE)) { $class = XOOPS_DB_ALTERNATIVE; } else { $class = 'icms_db_legacy_' . XOOPS_DB_TYPE; $class .= $allowWebChanges ? '_Safe' : '_Proxy'; } self::$xoopsInstance = new $class(); self::$xoopsInstance->setLogger(icms::$logger); if (!self::$xoopsInstance->connect()) { icms_loadLanguageFile('core', 'core'); trigger_error(_CORE_DB_NOTRACEDB, E_USER_ERROR); } } self::$xoopsInstance->setPrefix(XOOPS_DB_PREFIX); return self::$xoopsInstance; }