Included libraries | Package variables | General documentation | Methods |
WebCvs | Raw content |
connect | No description | Code |
db | No description | Code |
parse_dsn | No description | Code |
connect | description | prev | next | Top |
my ($self, $dsn) = @_; my %dsn = $self->parse_dsn($dsn); $db = DBI->connect( "DBI:mysql:host=" . $dsn{'host'} . ":port=" . $dsn{'port'} . ";database=" . $dsn{'database'}, $dsn{'user'}, $dsn{'pass'}, {'RaiseError' => 1}) || die "Can't connect to database\n"; return $db;}
db | description | prev | next | Top |
return $db; } 1;}
parse_dsn | description | prev | next | Top |
my ($self,$dsn) = @_; my %hash; my @bits = split /:/, $dsn; $hash{'host'} = $bits[1]; $hash{'port'} = $bits[2]; $hash{'database'} = $bits[3]; $hash{'user'} = $bits[4]; $hash{'pass'} = $bits[5]; return %hash; } # Connect to a database. Return DB connection.}