Jeremy Nixon wrote:
Here's the thing: if your database connection goes away, and Apache::DBI opens a new one, any prepared statement handles you might have become invalid, because prepared statements are per-connection.
The prepare_cached() method he's using will check the statement handle and prepare it again on the new connection if necessary.
My way around it is to not use prepared statements. The only cases I have where they would be of benefit would mean storing them across multiple requests, and with Apache::DBI, you can't do that.
You can store them across multiple requests, with or without Apache::DBI. They can be useful within a single request, if you need to issue the same statement multiple times.
- Perrin