I'm using DBIx::Class in a Catalyst app I am building. It works great, but sometimes I need to use my own db functions that I've developed that are very specific to my needs. Because of this, I need a dbh. However, since I'm already using DBIx::Class
I know that it already has a dbh that it is using. To avoid making another unnecessary connection to the database, I would like to just use the dbh that DBIx::Class
has already created. I know that the DBIx::Class::Storage::DBI module has two methods dbh
and dbh_do
, but I'm not really sure what the difference is between the two and if they are the best way to get access to the dbh. Can anyone tell me what the best way to get the dbh from DBIx::Class
would be in a Catalyst
app? I'd prefer a method that I could forward to that would store the dbh in the stash like below:
sub dbh :Private {
my ($self, $c) = @_;
$c->stash->{dbh} = #get dbh from DBIx::Class here
}
Thanks!