Changeset 222 for trunk/npemap.org.uk
- Timestamp:
- Oct 29, 2006, 5:02:35 PM (14 years ago)
- Location:
- trunk/npemap.org.uk/cgi
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/cgi/bad-postcode.fcgi
r215 r222 12 12 use vars qw($dbname $dbhost $dbuser $dbpass); 13 13 14 # Find our private perl libraries 15 use FindBin; 16 use lib "$FindBin::Bin/../perllib"; 17 use NPEMap; 18 14 19 sub print_err; 15 sub setup_dbh;16 17 # Read in database config18 my $config = 'npemap.conf';19 do $config or die "Can't read $config!\n";20 20 21 21 # Set up database handler to try and make sure it's ready for the first … … 23 23 # No point in handling errors here since they'll get handled by the request 24 24 # handler 25 my $dbh; 26 setup_dbh(); 25 my $dbh = setup_dbh(); 27 26 28 27 my $returnBaseURL = ''; … … 42 41 43 42 # In case the database went away, make sure we have a connection 44 unless ( setup_dbh()) {43 unless ($dbh = setup_dbh()) { 45 44 print_err('Error setting up database connection', $returnlink); 46 45 next REQUEST; … … 94 93 print "</body></html>\n"; 95 94 } 96 97 sub setup_dbh {98 # $dbh is global99 my $data_source = "dbi:Pg:dbname=$dbname";100 $data_source .= ";host=$dbhost" if $dbhost;101 return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);102 }103 -
trunk/npemap.org.uk/cgi/get-distant-postcodes.fcgi
r205 r222 17 17 use vars qw($dbname $dbhost $dbuser $dbpass); 18 18 19 # Find our private perl libraries 20 use FindBin; 21 use lib "$FindBin::Bin/../perllib"; 22 use NPEMap; 23 19 24 sub print_err; 20 sub setup_dbh;21 22 # Read in database config23 my $config = 'npemap.conf';24 do $config or die "Can't read $config!\n";25 26 25 27 26 # Set up database handler to try and make sure it's ready for the first … … 29 28 # No point in handling errors here since they'll get handled by the request 30 29 # handler 31 my $dbh; 32 setup_dbh(); 30 my $dbh = setup_dbh(); 33 31 34 32 … … 38 36 39 37 # In case the database went away, make sure we have a connection 40 unless ( setup_dbh()) {38 unless ($dbh = setup_dbh()) { 41 39 print_internal_err('Error setting up database connection'); 42 40 next REQUEST; … … 127 125 print "Error: $err\n"; 128 126 } 129 130 sub setup_dbh {131 # $dbh is global132 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 } -
trunk/npemap.org.uk/cgi/get-postcodes.fcgi
r195 r222 12 12 use vars qw($dbname $dbhost $dbuser $dbpass); 13 13 14 # Find our private perl libraries 15 use FindBin; 16 use lib "$FindBin::Bin/../perllib"; 17 use NPEMap; 18 14 19 sub print_err; 15 sub setup_dbh;16 17 # Read in database config18 my $config = 'npemap.conf';19 do $config or die "Can't read $config!\n";20 21 20 22 21 # Set up database handler to try and make sure it's ready for the first … … 24 23 # No point in handling errors here since they'll get handled by the request 25 24 # handler 26 my $dbh; 27 setup_dbh(); 25 my $dbh = setup_dbh(); 28 26 29 27 … … 36 34 37 35 # In case the database went away, make sure we have a connection 38 unless ( setup_dbh()) {36 unless ($dbh = setup_dbh()) { 39 37 print_internal_err('Error setting up database connection'); 40 38 next REQUEST; … … 105 103 print "Error: $err\n"; 106 104 } 107 108 sub setup_dbh {109 # $dbh is global110 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 } -
trunk/npemap.org.uk/cgi/interest.fcgi
r82 r222 13 13 use vars qw($dbname $dbhost $dbuser $dbpass); 14 14 15 # Find our private perl libraries 16 use FindBin; 17 use lib "$FindBin::Bin/../perllib"; 18 use NPEMap; 19 15 20 sub print_err; 16 sub setup_dbh;17 18 # Read in database config19 my $config = 'npemap.conf';20 do $config or die "Can't read $config!\n";21 21 22 22 my $returnlink='<a href="/">Go back</a>'; … … 26 26 # No point in handling errors here since they'll get handled by the request 27 27 # handler 28 my $dbh; 29 setup_dbh(); 28 my $dbh = setup_dbh(); 30 29 31 30 my $cgi; … … 34 33 35 34 # In case the database went away, make sure we have a connection 36 unless ( setup_dbh()) {35 unless ($dbh = setup_dbh()) { 37 36 print_err('Error setting up database connection', $returnlink); 38 37 next REQUEST; … … 104 103 print "</body></html>\n"; 105 104 } 106 107 sub setup_dbh {108 # $dbh is global109 my $data_source = "dbi:Pg:dbname=$dbname";110 $data_source .= ";host=$dbhost" if $dbhost;111 return $dbh = DBI->connect_cached($data_source, $dbuser, $dbpass);112 }113 -
trunk/npemap.org.uk/cgi/problem.fcgi
r154 r222 14 14 use vars qw($dbname $dbhost $dbuser $dbpass); 15 15 16 # Find our private perl libraries 17 use FindBin; 18 use lib "$FindBin::Bin/../perllib"; 19 use NPEMap; 20 16 21 sub print_err; 17 sub setup_dbh;18 19 # Read in database config20 my $config = 'npemap.conf';21 do $config or die "Can't read $config!\n";22 22 23 23 # Set up database handler to try and make sure it's ready for the first … … 25 25 # No point in handling errors here since they'll get handled by the request 26 26 # handler 27 my $dbh; 28 setup_dbh(); 27 my $dbh = setup_dbh(); 29 28 30 29 my $returnBaseURL = ''; … … 39 38 40 39 # In case the database went away, make sure we have a connection 41 unless ( setup_dbh()) {40 unless ($dbh = setup_dbh()) { 42 41 print_err('Error setting up database connection', $returnlink); 43 42 next REQUEST; … … 92 91 print "</body></html>\n"; 93 92 } 94 95 sub setup_dbh {96 # $dbh is global97 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 } -
trunk/npemap.org.uk/cgi/submit.fcgi
r169 r222 13 13 use vars qw($dbname $dbhost $dbuser $dbpass); 14 14 15 # Find our private perl libraries 16 use FindBin; 17 use lib "$FindBin::Bin/../perllib"; 18 use NPEMap; 19 15 20 sub print_err; 16 sub setup_dbh;17 18 # Read in database config19 my $config = 'npemap.conf';20 do $config or die "Can't read $config!\n";21 21 22 22 # Set up database handler to try and make sure it's ready for the first … … 24 24 # No point in handling errors here since they'll get handled by the request 25 25 # handler 26 my $dbh; 27 setup_dbh(); 26 my $dbh = setup_dbh(); 28 27 29 28 my @fields = qw(easting northing postcode1 postcode2); … … 46 45 47 46 # In case the database went away, make sure we have a connection 48 unless ( setup_dbh()) {47 unless ($dbh = setup_dbh()) { 49 48 print_err('Error setting up database connection', $returnlink); 50 49 next REQUEST; … … 165 164 print "</body></html>\n"; 166 165 } 167 168 sub setup_dbh {169 # $dbh is global170 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.