try {
    $db->openConnection();
    switch ($_POST['func']) {
        case 'savePlayer':
            // create club object
            $clubId = $_POST['clubId'];
            $club = $db->getClubById($clubId);
            // create player object
            $playerId = $db->getLastPlayerId();
            $playerName = $_POST['playerName'];
            $birthDate = $_POST['birthDate'];
            $position = $_POST['position'];
            $squadNumber = $_POST['squadNumber'];
            $player = new Player($playerId, $playerName, $birthDate, $position, $squadNumber, $club);
            // save player in database
            $db->savePlayer($player);
            // set json response value
            $response->setSuccesfull(true);
            $response->setMessage('Player has been saved.');
            break;
        case 'updatePlayerStats':
            $entryId = $_POST['entryId'];
            $player = $db->getPlayerById($_POST['playerId']);
            $appearances = $_POST['appearances'];
            $goals = $_POST['goals'];
            $assists = $_POST['assists'];
            $yellowCards = $_POST['yellow_cards'];
            $redCards = $_POST['red_cards'];
            $stat = new Statistics($entryId, $player, $appearances, $goals, $assists, $yellowCards, $redCards);
            $db->updatePlayerStats($stat);
            $response->setSuccesfull(true);