/** * Manage instance usage of this class */ public static function &getInstance($type = 'base') { if (key_exists($type, self::$dbCache)) { $db = self::$dbCache[$type]; vglobal('adb', $db); return $db; } else { if (key_exists('base', self::$dbCache)) { $db = self::$dbCache['base']; vglobal('adb', $db); return $db; } } $config = self::getDBConfig($type); $db = new self($config['db_type'], $config['db_server'], $config['db_name'], $config['db_username'], $config['db_password'], $config['db_port']); if ($db->database == NULL) { $db->log('Database getInstance: Error connecting to the database', 'error'); $db->checkError('Error connecting to the database'); return false; } else { self::$dbCache[$type] = $db; vglobal('adb', $db); } return $db; }
/** * Manage instance usage of this class */ static function &getInstance() { global $adb; if (!isset($adb)) { $adb = new self(); } if ($adb->database == NULL) { $adb->log('Database getInstance: Error connecting to the database', 'error'); $adb->checkError('Error connecting to the database', true); } return $adb; }