in reply to Modules and DBI
And connect by doing MyStateManagement::DBI::Singleton->connect(); the same way you would connect with DBI. Assuming you use one database handle for the whole package, subsequent connects will use the same connection, and will not regenerate the connect; however, you could change the singleton class to check to see if the connect string was the same, and create some sort of connect hash, if there were multiple connections (or you could just specify the connection by a number, or something of that sort.)package MyStateManagement::DBI::Singleton; use base qw(DBI); use DBI; my $Dbh = undef; sub connect { my $class = shift; $Dbh ||= DBI->connect( @_ ); return $Dbh; } 1;
|
|---|