in reply to Using DBI handle in several packages
Have every module do a 'my $dbh = MyDBI->connect(...)' and in your MyDBI module, the first call actually connects while subsequent calls just reuse the same handle (stored perhaps in a package global variable).
The disconnect would have to be at the end of the application I suppose.
Update: I take it all (well, most of it) back. Use connect_cached() and just let every module connect, just don't disconnect until the end of the app.
Another update:Looking at the docs for connect_cached(), I'm not sure the author really recommends it, so maybe my first suggestion is the way to go for production code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using DBI handle in several packages
by Beatnik (Parson) on Jun 03, 2001 at 02:09 UTC |