$year"; // Execute the query using appropriate MySQL function // Return the result } function updateUserUsername($id, $newUsername) { $query = "UPDATE users SET username = '$newUsername' WHERE id = $id"; // Execute the query using appropriate MySQL function } function getUserByEmail($email) { $query = "SELECT * FROM users WHERE email = '$email'"; // Execute the query using appropriate MySQL function // Return the result } function deleteUserByEmail($email) { $query = "DELETE FROM users WHERE email = '$email'"; // Execute the query using appropriate MySQL function } function getOldestUser() { $query = "SELECT * FROM users ORDER BY birthdate ASC LIMIT 1"; // Execute the query using appropriate MySQL function // Return the result } function getUserWithMostOrders() { $query = "SELECT u.*, COUNT(o.id) AS order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.id ORDER BY order_count DESC LIMIT 1"; // Execute the query using appropriate MySQL function // Return the result } function getLatestOrderDate($userId) { $query = "SELECT MAX(order_date) AS latest_order_date FROM orders WHERE user_id = $userId"; // Execute the query using appropriate MySQL function // Return the result } function getUserAndOrders($userId) { $query = "SELECT u.*, o.* FROM users u LEFT JOIN orders o ON u.id = o.user_id WHERE u.id = $userId"; // Execute the query using appropriate MySQL function // Return the result } function getTotalOrderAmount($userId) { $query = "SELECT SUM(amount) AS total_amount FROM orders WHERE user_id = $userId"; // Execute the query using appropriate MySQL function // Return the result } function getUserWithLongestEmail() { $query = "SELECT * FROM users ORDER BY LENGTH(email) DESC LIMIT 1"; // Execute the query using appropriate MySQL function // Return the result } ?>