How 'bout this:

http://perl.apache.org/guide/performance.html#Persistent_DB_Connections

--Jeff

At 04:39 PM 11/27/99 -0500, Aaron Johnson wrote:
>I am using HTML::Embperl in conjunction with Apache::Session to control
>session information and create pages.  I have started to create a module
>that will trim the amount of code and keep a connection with MySQL
>engine alive.  Below is a section of my module.
>     My problem is that when I connect again with a different computer my
>connect all my previous connects are changed to the last one.
>
>So in short:
>
>Can I assign each session a seperate "permanent" connection?
>
>Aaron Johnson
>
># I pass this -> $dbh = db_connect( { database => "$udat{location}",
>change => 1, } );
># for those of you who haven't used HTML::Embperl $udat{location} is
>session data
>
>sub db_connect {
>  my $pd = shift;
>  if ($pd->{change}) { &db_disconnect };
>  if ($pd->{change} || !$dbh) {
>
>  $dbh=DBI->connect(
>     "dbi:mysql:$pd->{database}", 'user', 'password', {
>          PrintError => 1,
>                 RaiseError => 1,
>         }
>         ) || die $DBI::errstr;
>
>  return($dbh)
>  }
>
>  else {
>   # warn "No need to change!\n";
>   return($dbh)
>  }
>
>}



Jeff Beard
Web Systems Engineer
World Wide Web Associates
Web: http://wwwa.com
Phone: 303.545.2399

Reply via email to