Ignore:
Timestamp:
Oct 29, 2006, 5:02:35 PM (15 years ago)
Author:
Dominic Hargreaves
Message:

Make everything use the modules

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/cgi/problem.fcgi

    r154 r222  
    1414use vars qw($dbname $dbhost $dbuser $dbpass);
    1515
     16# Find our private perl libraries
     17use FindBin;
     18use lib "$FindBin::Bin/../perllib";
     19use NPEMap;
     20
    1621sub print_err;
    17 sub setup_dbh;
    18 
    19 # Read in database config
    20 my $config = 'npemap.conf';
    21 do $config or die "Can't read $config!\n";
    2222
    2323# Set up database handler to try and make sure it's ready for the first
     
    2525# No point in handling errors here since they'll get handled by the request
    2626# handler
    27 my $dbh;
    28 setup_dbh();
     27my $dbh = setup_dbh();
    2928
    3029my $returnBaseURL = '';
     
    3938
    4039    # In case the database went away, make sure we have a connection
    41     unless (setup_dbh()) {
     40    unless ($dbh = setup_dbh()) {
    4241        print_err('Error setting up database connection', $returnlink);
    4342        next REQUEST;
     
    9291    print "</body></html>\n";
    9392}
    94 
    95 sub setup_dbh {
    96     # $dbh is global
    97     my $data_source = "dbi:Pg:dbname=$dbname";
    98     $data_source .= ";host=$dbhost" if $dbhost;
    99     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    100 }
Note: See TracChangeset for help on using the changeset viewer.