/** * calls and sets the parent instance method, and if !MULTIPROVIDER * checks if module_login_providers table is in the provider db. * * If found, use the provider DB else use the common * * @param string $dsn */ static function instance($dsn = null) { if (!MULTIPROVIDER && is_null($dsn)) { $dsn = MultiPort::getDSN($GLOBALS['user_provider']); } $theInstance = parent::instance($dsn); if (is_null(self::$dbToUse)) { self::$dbToUse = AMA_Common_DataHandler::instance(); if (!MULTIPROVIDER && !is_null($dsn)) { // must check if passed $dsn has the module login tables // execute this dummy query, if result is not an error table is there $sql = 'SELECT NULL FROM `' . self::$PREFIX . 'providers`'; // must use AMA_DataHandler because we are not able to // query AMALoginDataHandelr in this method! $ok = AMA_DataHandler::instance($dsn)->getOnePrepared($sql); if (!AMA_DB::isError($ok)) { self::$dbToUse = $theInstance; } } } return $theInstance; }