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-distant-postcodes.fcgi

    r205 r222  
    1717use vars qw($dbname $dbhost $dbuser $dbpass);
    1818
     19# Find our private perl libraries
     20use FindBin;
     21use lib "$FindBin::Bin/../perllib";
     22use NPEMap;
     23
    1924sub print_err;
    20 sub setup_dbh;
    21 
    22 # Read in database config
    23 my $config = 'npemap.conf';
    24 do $config or die "Can't read $config!\n";
    25 
    2625
    2726# Set up database handler to try and make sure it's ready for the first
     
    2928# No point in handling errors here since they'll get handled by the request
    3029# handler
    31 my $dbh;
    32 setup_dbh();
     30my $dbh = setup_dbh();
    3331
    3432
     
    3836
    3937    # In case the database went away, make sure we have a connection
    40     unless (setup_dbh()) {
     38    unless ($dbh = setup_dbh()) {
    4139        print_internal_err('Error setting up database connection');
    4240        next REQUEST;
     
    127125    print "Error: $err\n";
    128126}
    129 
    130 sub setup_dbh {
    131     # $dbh is global
    132     my $data_source = "dbi:Pg:dbname=$dbname";
    133     $data_source .= ";host=$dbhost" if $dbhost;
    134     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    135 }
Note: See TracChangeset for help on using the changeset viewer.