7 |
############################################ |
############################################ |
8 |
# |
# |
9 |
# $Log$ |
# $Log$ |
10 |
|
# Revision 1.9 2002/12/01 22:15:45 joko |
11 |
|
# - sub createDb: moved to handler |
12 |
|
# |
13 |
# Revision 1.8 2002/11/29 04:48:23 joko |
# Revision 1.8 2002/11/29 04:48:23 joko |
14 |
# + updated pod |
# + updated pod |
15 |
# |
# |
365 |
if ( my $dbh = DBI->connect($dsn, '', '', { |
if ( my $dbh = DBI->connect($dsn, '', '', { |
366 |
PrintError => 0, |
PrintError => 0, |
367 |
} ) ) { |
} ) ) { |
368 |
|
|
369 |
|
# TODO: REVIEW |
370 |
$dbh->disconnect(); |
$dbh->disconnect(); |
371 |
|
|
372 |
return 1; |
return 1; |
373 |
} else { |
} else { |
374 |
$logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); |
$logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); |
382 |
return $status; |
return $status; |
383 |
} |
} |
384 |
|
|
|
sub createDb { |
|
|
my $self = shift; |
|
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
|
|
|
|
|
$logger->debug( __PACKAGE__ . "->createDb( dsn $dsn )" ); |
|
|
|
|
|
$dsn =~ s/database=(.+?);//; |
|
|
my $database_name = $1; |
|
|
|
|
|
my $ok; |
|
|
|
|
|
if ( my $dbh = DBI->connect($dsn, '', '', { |
|
|
PrintError => 0, |
|
|
} ) ) { |
|
|
if ($database_name) { |
|
|
if ($dbh->do("CREATE DATABASE $database_name;")) { |
|
|
$ok = 1; |
|
|
} |
|
|
} |
|
|
$dbh->disconnect(); |
|
|
} |
|
|
|
|
|
return $ok; |
|
|
|
|
|
} |
|
385 |
|
|
386 |
sub dropDb { |
sub dropDb { |
387 |
my $self = shift; |
my $self = shift; |
402 |
$ok = 1; |
$ok = 1; |
403 |
} |
} |
404 |
} |
} |
405 |
|
|
406 |
$dbh->disconnect(); |
$dbh->disconnect(); |
407 |
|
|
408 |
} |
} |
409 |
|
|
410 |
return $ok; |
return $ok; |