[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Plugin-DBH questions


On 11/16/06, Dan Horne <suppressed> wrote:
On Wed, 2006-11-15 at 21:51 -0500, Chris Beck wrote:
> If I don't want lazy-loading should I just create my own DBH?  (I want to die as
> soon as possible if the DB connection isn't working)
>

My guess is this case is that the plugin isn't giving you any value, and
you may as well create the handle yourself in the init phase:

my $dbh = DBI->connect($dsn,$user,$pass) || _do_db_dead(DBI:errstr);
$self->param('dbh', $dbh);


and then when you need the database handle in your run modes

my $dbh = $self->param('dbh');
.. carry on coding...

The plugin can still give some value by doing things in a standard way
that will not surprise others when they come across your code.  It
also may help with the use of other plugins.  For example, the
Authentication plugin has a database driver that will default to
calling $self->dbh if it needs a database handle and none was provided
in the configuration.

Cheers,

Cees

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.