home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Mysql.pm < prev    next >
Encoding:
Perl POD Document  |  2002-06-13  |  1.7 KB  |  73 lines

  1. package Apache::Mysql;
  2.  
  3. use strict;
  4. use Mysql();
  5.  
  6. my %Connected;
  7.  
  8. sub connect {
  9.     my($self, @args) = @_;
  10.     my $idx;
  11.     if ($#args == -1) { 
  12.     $idx = $self; 
  13.     } else { 
  14.     $idx = join (':', @args); 
  15.     }
  16.     return (bless $Connected{$idx}) if $Connected{$idx};
  17.  
  18. # only uncomment out the following line to see the connections in error_log 
  19. #   print STDERR "Pid = $$, Apache::Mysql connect to $idx\n"; 
  20.  
  21.     $Connected{$idx} = Mysql->Connect(@args);
  22.     return (bless $Connected{$idx});
  23. }
  24.  
  25. sub DESTROY {
  26. }
  27.  
  28. { package Apache::Mysql;
  29.   no strict;
  30.   @ISA=qw(Mysql);
  31.   use strict;
  32. }
  33.  
  34.  
  35. 1;
  36.  
  37. __END__
  38.  
  39. =head1 NAME
  40.  
  41. Apache::Mysql - Initiate a persistent database connection to Mysql
  42.  
  43. =head1 SYNOPSIS
  44.  
  45.  use Apache::Mysql;
  46.  
  47.  $dbh = Apache::Mysql->connect(...);
  48.  
  49. =head1 DESCRIPTION
  50.  
  51. This module supplies a persistent database connection to Mysql. You will need to have mysqlperl installed on your system. You should really use Apache::DBI instead of this module (this module was written when DBI::Mysql had problems, which have since been corrected).
  52.  
  53. This is the first version of the first module I have ever written, so expect errors! Any feedback or suggestions are gratefully received.
  54.  
  55. All you really need is to replace Mysql with Apache::Mysql.
  56. When connecting to a database the module looks if a database
  57. handle from a previous connect request is already stored. If
  58. not, a new connection is established and the handle is stored
  59. for later re-use. The destroy method has been intentionally
  60. left empty.
  61.  
  62. =head1 SEE ALSO
  63.  
  64. Apache(3), Mysql(3)
  65.  
  66. =head1 AUTHORS
  67.  
  68.  MySQL and mysqlperl by Michael (Monty) Widenius <month@tcx.se>
  69.  mod_perl by Doug MacEachern <dougm@osf.org>
  70.  Apache::Mysql by Neil Jensen <njensen@habaneros.com>
  71.  
  72.  
  73.