LJ Archive

Listing 2: database-connect.comp

<%perl>
my $database = "atf";
my $dbhost = "localhost";
my $port = 3306;
my $user = "atf";
my $password = "atfpass";

my $dsn =
"DBI:mysql:database=$database;host=$dbhost;port=$port";
$dbh = DBI->connect($dsn, $user, $password);

# Make sure that we got a database handle!
die unless $dbh;

# Return $dbh to the caller
return $dbh;
</%perl>

<%once>
my $dbh;
</%once>
LJ Archive