in reply to Re: Re: Problem managing persistent database connections in modules
in thread Problem managing persistent database connections in modules

In that project, I had each class which needed access to the DB call MyProject::DBH->get_dbh in its constructor and store the returned database handle in the instance data. Then, it's available for each method that needs it in $self->{'dbh'}.

You could just as easily make the DBH a package variable, but doing it this way seemed "neater" despite the increaed number of calls to get_dbh.

  • Comment on Re: Re: Re: Problem managing persistent database connections in modules