I've no doubt been coding messily to date - but am trying to tidy up and optimise our Radiator code. At the moment we (I) use code like: (as an excerpt from a Hook) ---------------------------------------------------------------------- my $dbh = DBI->connect("DBI:mysql:xxxx:xxxxx","radius","xxxxxxx"); my $query = $dbh->prepare("select visp, plannow from users where login='$USERNAME' "); $query->execute if (my @q1 = $query->fetchrow_array) { my $visp = @q1[0]; my $plannow = @q1[1]; if ( $visp eq "our.virtual.isp" ) { $reply->add_attr('PoolHint', "VISPPOOL"); } if ( plannow eq "budget" ) { $reply->add_attr('PoolHint', "CHEAPPOOL"); } } $query = ""; $dbh->disconnect || warn $dbh->errstr; ---------------------------------------------------------------------- This works, but is obviously very inefficient in terms of database connects, etc. Is there a way to connect in a Startup Hook and disconnect in a Shutdown Hook and then use this database object throughout all our hooks (there's about 5 of them which use database lookups) ? [Forgive the question if it's simple -- i'm not that up to the play with perl object handling, and tend to be a code-duplicator and refiner] Also -- is there a "programmers" guide (wishlist!) on how to programme within Hooks? [or do bits of the "addingcustom AuthBy modules" apply - and if so which bits?] ......................................................................... Mark Mackay, Network Coordinator, Orcon Internet. === Archive at http://www.starport.net/~radiator/ Announcements on [EMAIL PROTECTED] To unsubscribe, email '[EMAIL PROTECTED]' with 'unsubscribe radiator' in the body of the message.
(RADIATOR) Using databases (efficiently) in Hooks
Orcon Network Coordinator, Mark Mackay Tue, 18 Jul 2000 18:49:59 -0700
- Re: (RADIATOR) Using databases (eff... Orcon Network Coordinator, Mark Mackay
- Re: (RADIATOR) Using databases... Hugh Irvine