in reply to OO Perl: classes and database access

I like to do this by putting the database stuff in the constructor of the data object. However, I usually make three methods: load, save, and new. You call new when making an object that isn't in the database yet (a new one!), load - with an ID - to load one from the database, and save to save changes to an object.

I'm wary of object/relational mapping tools for various reasons, but a lot of people seem to like SPOPS and Class::DBI for automating these steps. If your objects map to database tables in a simple way, these could save you some coding.

  • Comment on Re: OO Perl: classes and database access