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/get-postcodes.fcgi

    r195 r222  
    1212use vars qw($dbname $dbhost $dbuser $dbpass);
    1313
     14# Find our private perl libraries
     15use FindBin;
     16use lib "$FindBin::Bin/../perllib";
     17use NPEMap;
     18
    1419sub print_err;
    15 sub setup_dbh;
    16 
    17 # Read in database config
    18 my $config = 'npemap.conf';
    19 do $config or die "Can't read $config!\n";
    20 
    2120
    2221# Set up database handler to try and make sure it's ready for the first
     
    2423# No point in handling errors here since they'll get handled by the request
    2524# handler
    26 my $dbh;
    27 setup_dbh();
     25my $dbh = setup_dbh();
    2826
    2927
     
    3634
    3735    # In case the database went away, make sure we have a connection
    38     unless (setup_dbh()) {
     36    unless ($dbh = setup_dbh()) {
    3937        print_internal_err('Error setting up database connection');
    4038        next REQUEST;
     
    105103    print "Error: $err\n";
    106104}
    107 
    108 sub setup_dbh {
    109     # $dbh is global
    110     my $data_source = "dbi:Pg:dbname=$dbname";
    111     $data_source .= ";host=$dbhost" if $dbhost;
    112     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    113 }
Note: See TracChangeset for help on using the changeset viewer.