in reply to Re: Re: DBI handle destroyed during CGI::Application setup
in thread DBI handle destroyed during CGI::Application setup
Some sample CGI::Application code using DBI handles follows - Note that my usage of the param function differs slightly as I prefer to define my parameters through the instance object of my CGI::Application class.
#!/usr/bin/perl use DBI; use strict; my $app = self->new( TMPL_PATH => "../templates/", PARAMS => { 'dbh' => DBI->connect( "DBI:mysql:database=apex;host=localhost", undef, undef ), 'mode_param' => "stage" } ); $app->run; exit 0; package self; use base qw/CGI::Application/; use strict; sub setup { my $self = shift; $self->start_mode('display'); $self->run_modes({ 'AUTOLOAD' => 'display_calendar' }); $self->mode_param($self->param('mode_param')); }; sub teardown { my $self = shift; $self->param('dbh')->disconnect; }; . . . 1; __END__
perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (4) DBI handle destroyed during CGI::Application setup
by talexb (Chancellor) on Jan 07, 2002 at 21:27 UTC | |
by Anonymous Monk on Jan 08, 2002 at 05:27 UTC |