Leser: 1
6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
package Kale_1990::Database;
use strict;
use warnings;
use DBI;
use base qw(Exporter);
our @EXPORT = qw($dbh);
my ($user,$pass,$db,$host) = ("username","password","datenbank","host");
our $dbh = DBI->connect("DBI:mysql:$db:$host",$user,$pass) or die $DBI::errstr;
1
2
3
4
5
6
7
8
9
10
11
12
13
package Kale_1990::Database;
use strict;
use warnings;
use DBI;
use DBD::mysql;
sub connect {
my $class = shift;
my ($user,$pass,$db,$host) = @_;
my $dbh = DBI->connect("DBI:mysql:$db:$host",$user,$pass) or die $DBI::errstr;
return $dbh;
}
1
2
3
4
use Kale_1990::Database;
my $dbh = connect Kale_1990::Database;
my $sth = $dbh->prepare('...');
6 Einträge, 1 Seite |