in reply to Using a single DBI handle in a script and a module
Step 1. Connect to the database, and get a database handle. You could do this in your main script, or in the module. If you do it in the module, have it return the database handle to the main script, like this:
Step 2. Pass the database handle to each sub in the module as needed, e.g. select_cakes_by_type($dbh, 'battenburg');In the module: sub george_connect { return DBI->connect('yada yada'); } In the main script: my $dbh = george_connect;
Step 3. Disconnect in module or main script.
hth,
andy.
update: works fine with Apache::DBI
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using a single DBI handle in a script and a module
by Masem (Monsignor) on Nov 14, 2001 at 19:29 UTC |