What are some common pitfalls when using PDO in PHP, as seen in the provided code snippet?

One common pitfall when using PDO in PHP is not properly handling exceptions that may occur during database operations. This can lead to uncaught errors and potential security vulnerabilities. To solve this issue, it is important to wrap PDO operations in try-catch blocks to handle exceptions gracefully.

try {
    $pdo = new PDO("mysql:host=localhost;dbname=myDB", "username", "password");
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    // Perform database operations here

} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}