in reply to Hash Tie's DESTROY & DBI

Many moons ago my uni lecturer told us we cant test for everything because we will never know all the possible combinations of run-time variables that could occur.

Given that she also said that we should attempt to trap everything in a generic method reporting back any errors via logs, emails, or whatever was appropriate for the system being built.

Having said all that, there are a few things that could go wrong, for example null values and most obviously your dbi calls.

As the others have mentioned, add some error handling to see what is going on in your code, and whatever you do make sure you are using -w and strict.

As an aside, if this is is going to be a part of an object, it will be called many times. To increase performance, have you considered using bind vars in your code?

I'm not sure if this specifically applies to mysql, however with oracle and postresql, if you make a call to the database the sql is cached in the database. What this means, is when the DB engine gets the a statement, it will compare it to what it has in memory and use the memory cached version, rather than the one being parsed, thus saving on expensive I/O.

If you dont use placeholders (bindvars) in your code, each statement is potentially different, and thus the db cache is filled with useless statements that are only ever executed once.

Using placeholders, means that all the statements are the same as the variables in them are the placeholders ("?") so the db can re-use it.

Its a smart, easy and efficient style to code in that will make your application more scalable. Its so simple to do, i dont know why people dont, when they can.

Yet again i digress from the topic at hand... <sigh>