What are some potential pitfalls when using PDO for database connections in PHP?

One potential pitfall when using PDO for database connections in PHP is not properly handling exceptions that may occur during database operations. It is important to catch and handle these exceptions to prevent them from being displayed directly to users, which could expose sensitive information about the database structure or data.

try {
    $pdo = new PDO("mysql:host=localhost;dbname=mydatabase", "username", "password");
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}