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/submit.fcgi

    r169 r222  
    1313use vars qw($dbname $dbhost $dbuser $dbpass);
    1414
     15# Find our private perl libraries
     16use FindBin;
     17use lib "$FindBin::Bin/../perllib";
     18use NPEMap;
     19
    1520sub print_err;
    16 sub setup_dbh;
    17 
    18 # Read in database config
    19 my $config = 'npemap.conf';
    20 do $config or die "Can't read $config!\n";
    2121
    2222# Set up database handler to try and make sure it's ready for the first
     
    2424# No point in handling errors here since they'll get handled by the request
    2525# handler
    26 my $dbh;
    27 setup_dbh();
     26my $dbh = setup_dbh();
    2827
    2928my @fields = qw(easting northing postcode1 postcode2);
     
    4645
    4746    # In case the database went away, make sure we have a connection
    48     unless (setup_dbh()) {
     47    unless ($dbh = setup_dbh()) {
    4948        print_err('Error setting up database connection', $returnlink);
    5049        next REQUEST;
     
    165164    print "</body></html>\n";
    166165}
    167 
    168 sub setup_dbh {
    169     # $dbh is global
    170     my $data_source = "dbi:Pg:dbname=$dbname";
    171     $data_source .= ";host=$dbhost" if $dbhost;
    172     return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);
    173 }
    174 
Note: See TracChangeset for help on using the changeset viewer.