in reply to DBI::mySQL - philosophical question?
Now that I'm converting to 'use strict', each subfunction is naturally enough forcing me to declare the $dbh within it. So I presume my options are:My $0.02:
- declare $dbh as a global variable, use 'our' within the subfunctions and carry on with a single connection.
- connect and disconnect to the database for each separate database query.
I'd say that the most "clean" way would be to pass the database handle ($dbh) as a parameter to the function.
This will at least make it possible to move the functions (and the calling code) to other packages and/or files without hassle (at the cost of having slightly more characters to type for each call).
HTH,
Joost.
|
|---|