[CDBI] Is standard idiom for transactions really safe?
perrin at elem.com
Thu Mar 2 16:10:13 GMT 2006
Phil Mitchell wrote:
> connect_cached *tries* to return the same dbh, but
> afaik can't guarantee it. And in the rare event that dbh changes in the
> middle of a transaction, the new dbh will not have AutoCommit turned off.
That would be a very rare event. It is possible, but would involve
either your code cutting the connection after changing AutoCommit, or
the database server failing at just the right point for just the right
amount of time, and in way that mysql_auto_reconnect can't deal with.
If you're really worried about it, you could create a global
"TRANSACTION_ACTIVE" flag, and modify Ima::DBI to throw an exception
instead of reconnecting if it sees that.
More information about the ClassDBI