setErrorHandler(array('DB', 'errorHandler')); if ($interface->error) die('Failed to connect to database.'); $interface->query('SET NAMES ?', 'utf8'); if ($options['prefix']) $interface->setIdentPrefix($options['prefix']); self::$interfaceCache[$idx] = &$interface; self::$connectionCache[$idx] = true; } public static function errorHandler($message, $data) { if (!error_reporting()) return; echo "DB ERROR:

\n\n
";
        print_r($data);
        echo "
"; exit; } public static function getDB($idx) { return self::$interfaceCache[$idx]; } public static function isConnected($idx) { return isset(self::$connectionCache[$idx]); } private static function safeGetDB($idx) { if(!self::isConnected($idx)) self::connect($idx); return self::getDB($idx); } /** * @static * @return DbSimple_Mysql */ public static function Characters($realm_id) { if (!isset(self::$optionsCache[DB_CHARACTERS+$realm_id])) die('Connection info not found for live database of realm #'.$realm_id.'. Aborted.'); return self::safeGetDB(DB_CHARACTERS+$realm_id); } /** * @static * @return DbSimple_Mysql */ public static function Auth() { return self::safeGetDB(DB_AUTH); } /** * @static * @return DbSimple_Mysql */ public static function World() { return self::safeGetDB(DB_WORLD); } /** * @static * @return DbSimple_Mysql */ public static function Aowow() { return self::safeGetDB(DB_AOWOW); } public static function load($idx, $config) { self::$optionsCache[$idx] = $config; } } ?>