What are some best practices for incorporating user points into a PHP-based game system?

Issue: Incorporating user points into a PHP-based game system requires a structured approach to ensure accurate tracking and updating of points for each user. Code snippet:

// Function to retrieve user points from the database
function getUserPoints($userId) {
    // Code to query database and retrieve user points
    return $userPoints;
}

// Function to update user points in the database
function updateUserPoints($userId, $points) {
    // Code to update user points in the database
}

// Example usage:
$userId = 1;
$userPoints = getUserPoints($userId);

// Update user points
$newPoints = $userPoints + 10;
updateUserPoints($userId, $newPoints);