in reply to CGI Application and global variables (from a database)
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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: CGI Application and global variables (from a database)
by tmaciak (Initiate) on Dec 19, 2003 at 18:35 UTC |