geektron has asked for the wisdom of the Perl Monks concerning the following question:
from reading the perldoc, the online guide, and Writing Apache Modules w/ Perl and C ... i can use DBI normally in a handler, and the caching, etc is transparent. but i'm not seeing anything DBI-related with this handler:#!/usr/local/bin/perl use strict; use lib qw( /webcontent/server_home/rentsavers/test ); $ENV{MOD_PERL} or die "not running mod_perl!: $! \n"; use Apache::Registry; use Apache::DBI (); use DBI (); # Initialize the database connections for each child Apache::DBI->connect_on_init ("DBI:mysql:database=test;host=localhost", "testuser", { PrintError => 1, # warn() on errors RaiseError => 0, # don't die on error AutoCommit => 1, # commit executes immediately } ); 1;
am i missing something really obvious? or is there a bigger problem?package My::Greeting; use strict; use Apache::Constants qw(OK); use Data::Dumper; use DBI; sub handler { my $r = shift; my $now = scalar localtime; my $server_name = $r->server->server_hostname; $r->send_http_header('text/plain'); print <<EOT; Thanks for visiting $server_name. The local time is $now. EOT my $DBH || DBI->connect( "dbi:mysql:localhost", "rentsaver", "ro +ot" ) ; Dumper( $DBH ); return OK; } 1;
|
|---|