|We don't bite newbies here... much|
Seeking guidance for web/db applicationby neilwatson (Priest)
|on Mar 13, 2014 at 18:29 UTC||Need Help??|
neilwatson has asked for the
wisdom of the Perl Monks concerning the following question:
I seldom venture in the web end of the Perl pool, but am doing so now and I seek your advice. I'm using Mojolicious and I'm thinking about how to divide up my code. I was thinking of using a module for database functions, but am wondering how I'm going to pass DB handles back and forth. For example:
And the main app:
I don't want to make unneeded connections because not all pages will require the database. I don't know if handle passing like this is the best approach. How would you do it? Passing $dbh around is a bit fiddly. Is there a better way?