/** * Connects to game DB * * @return a DB link */ function connectToGameDB() { global $config; $db_game = new Db($config->DB_GAME_HOST, $config->DB_GAME_USER, $config->DB_GAME_PWD, $config->DB_GAME_NAME); if (!$db_game) { inactives_log('Failed to connect to login DB.'); exit(1); } return $db_game; }
/** * Marks players as to with the 'deleted' flag * * @param players * an array of players * @param dblogin * the link to the login DB */ function inactives_markAsDeleted($players, $db_login) { global $debugFlag; // check $players if (0 == sizeof($players)) { return; } // collect playerIDs $playerIDs = array(); foreach ($players as $player) { inactives_log('possibly inactive player: %d, %s', $player['playerID'], $player['name']); $playerIDs[] = $player['playerID']; } // join them $playerIDs = implode(", ", $playerIDs); // prepare query $query = sprintf('UPDATE Login SET deleted = 1 WHERE activated = 1 AND ' . 'LoginID IN (%s)', $playerIDs); // send query if ($debugFlag) { inactives_log('%s (%d): %s', __FUNCTION__, __LINE__, $query); } else { $db_login->query($query); } }