in reply to $dbh->prepare not triggering die
prepare() is a funny beast. For many databases, it does a "please ignore the man behind the curtain" trick, saving the query until execute() time, when placeholders are expanded by the driver before sending the complete query over the wire to the server. In these case, errors in the query aren't detected until you try to execute().
Why is this? It's so that we can have a generic, RDBMS-independent API. Some databases don't support reusable queries. Others (e.g., Postgress) are just now supporting them. But by coding as if your database supports prepared queries, you're setting yourself up to benefit from performance gains if and when support for them is added.
But even if you're using a database that supports reusable queries, you want to check for errors at both prepare() and execute() time, since errors can happen at both.
|
|---|