I would like to trace the type of error that occurred while executing a query using PDO prepare and execute.
For example, if I had to insert email, Name, DOB, with the email requiring to be unique, instead of writing a special query to check if Email is already taken, I would like to trace the error that occurred and know the same.
You could use a try/catch block around the insert query and handle the double email in the exception handler.
Of course you must configure PDO that it throws exceptions on errors.