Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Avoiding too many DB queries

by EvdB (Deacon)
on Jun 17, 2004 at 17:04 UTC ( #367685=note: print w/replies, xml ) Need Help??

in reply to Avoiding too many DB queries

The comments above suggest that you cut out the repeated database connections. This code might be a good place for you start:
sub dbi_connect { my $self = shift; return $$self{dbh} ||= DBI->connect($dbi,$u,$p,{'RaiseError' => 1}); } sub dbi_disconnect { my $self = shift; return 1 unless $$self{dbh}; my $dbh = $self->dbi_connect; $dbh->disconnect || die $dbh->errstr; $$self{dbh} = undef; return 1; }
Obviously you should only call dbi_disconnect when you are finished with the db handle. Alternatively just let it get disconnected automatically when the object goes out of scope.

--tidiness is the memory loss of environmental mnemonics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367685]
[Corion]: Also suffering is my 2-factor Github sign-in, as now, FF can't read my USB token anymore. "This was a horrible idea" is slowly dawning on me ;)
[Corion]: Yay. FF now has u2f built-in (behind an about:config setting), so using an USB token to sign in actually works :)
[Corion]: So, it's not all bad with the new FF :)
[holli]: 2factor is a bit too much for me. i just use passwords like jhbn8789q27312laks dmaw98^
[moritz]: isn't there also some about:config setting to enable the old plugin API?
[Discipulus]: indeed, only the logo is nicer

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-11-20 20:19 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (293 votes). Check out past polls.