How to squeeze error message out of PDO? [duplicate]

setAttribute will cause PDO to throw up errors or exceptions – the latest when you execute the query.

For emulated prepared statements, there is no check in prepare():

Emulated prepared statements does not communicate with the database server so PDO::prepare() does not check the statement.

But there will be one in execute() when the query gets sent to the server.

However, the mySQL driver supports native prepared statements since mySQL 4.1 anyway, so this shouldn’t apply. Using


must cause an exception for the query you use.

Leave a Comment