in reply to MySQL / DBI / OOP

Something important that nobody said.

It is a really bad idea to rely on knowing the order of columns in a database. You have a table with 20 columns. You have an insert with 20 values. If the order is off slightly, have fun debugging! As columns are added or dropped, this will be a constant source of bugs. (Just imagine if some future DBA has to do a database migration and happens to reorder the columns. Then your scripts all have to work against that..?)

This is typically an issue any time you use positional based logic. Associating things by name works much better.

Therefore if the code is not performance critical, I would strongly suggest storing the data structure to insert in an anonymous hash, and then dynamically construct the insert statement from that, walking the keys to get the field names, and values to get the values, and using the syntax:

my $sql = qq( insert into foo (bar, baz) values (?, ?) );
so that there is no possibility of a synchronization error.