From: Chris Faust <[EMAIL PROTECTED]>

> Thanks Paul, that tells me to stop going crazy over it at least :)..

Yeah, don't go crazy.


I didn't see this in the thread, so I'll include it; a snippet from the Apache::DBI 
docs:

  PerlModule Apache::DBI  # this comes before all other modules using DBI

  Do NOT change anything in your scripts. The usage of this
  module is absolutely transparent ! 



> The difference in performance between now and before mod_perl is just so
> amazing I was trying to squeeze everything I could out of it.

If Perl loading was a big problem for you, then mod_perl should provide an enormous 
win. There are some things to be careful of with mod_perl and DBI, but they are rare. 
A quick example, a lot of our scripts declare their own package name:

  # test.mpl

  # Some set up work here...
  my $obj = TestModPerl->new;

  # Other optional stuff here.

  package TestModPerl;

  sub new {
    # get a DB connection and do other things.
  }

  # Methods that do the work


If this were a straight CGI script, the DB handled would go out of scope at program 
termination and the connection would close. In mod_perl, the DB handle's DESTROY() 
method will NEVER be called, and the connection will stay open without ever getting 
used again. The result? You run out of connections as soon as you have handled 
max_connections requests. To solve this, just use Apache::DBI like shown in the docs.


By the way, your first post included this piece of code:

  my $database = "DBI:mysql:database=$db_name:host=$db_location";
  $db = DBI->connect($database,$db_username,$db_password) or
    die "Cannot Connect: " . $db->errstr();

This won't quite work. If the DB connection fails, then $db won't be defined and you 
won't be able to say: $db->errstr(). Instead, your statement could read:

  $db = DBI->connect($database,$db_username,$db_password) or
    die "Cannot Connect: " . $DBI::errstr;


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to