Generally you are going to connect to the database in the setup subroutine and you set the param $self->param('mydbh' => DBI->connect('DBI:mysql:appname', 'xxxxx', 'xxxxx')); then in the cgiapp_prerun I do a variety of things including validating sessions and requiring logins etc. You can get the database handle and then set up more global values here, he is a simple cgiapp_prerun I am using right now:
Does that help?sub cgiapp_prerun { # If user has a session ID then validate it, otherwise get them on +e my $self = shift; my $dbh = $self->param('mydbh'); my $q = $self->query(); my $session_h = new CGI::Session("driver:MySQL", $q, {Handle => $d +bh}); $self->param('up_session' => $session_h); }
In reply to Re: CGI Application and global variables (from a database)
by jdtoronto
in thread CGI Application and global variables (from a database)
by tmaciak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |