in reply to Creating a Flexible Database Module

Consider hiding the technical differences behind an interface. Create a module with methods that have business related names, not technical names.

For instance, name a method $sql->get_account_details() instead of $sql->select_act().

Let this module work out where and how to find the data you're looking for and return a hashref or an arrayref, whichever is more appropriate.

This way your main application will not know anything about the database structure, but just ask for (and hopefully get) business related information. Of course, the same goes for saving data. This way you can 'easily' add another database definition when using the software for a different client with a different db.

Update: You should probably also consider naming the $sql something more generic, like $db or $storage just to avoid the assumption of an SQL database.

"Livet är hårt" sa bonden.
"Grymt" sa grisen...

  • Comment on Re: Creating a Flexible Database Module