Revision 61bd0898
Von Moritz Bunkus vor etwa 18 Jahren hinzugefügt
SL/User.pm | ||
---|---|---|
355 | 355 |
|
356 | 356 |
my ($self, $form) = @_; |
357 | 357 |
|
358 |
$form->{sid} = $form->{dbdefault}; |
|
359 |
&dbconnect_vars($form, $form->{dbdefault}); |
|
360 |
my $dbh = |
|
361 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
362 |
or $form->dberror; |
|
363 |
|
|
358 | 364 |
my %dbcreate = ( |
359 | 365 |
'Pg' => qq|CREATE DATABASE "$form->{db}"|, |
360 | 366 |
'Oracle' => |
361 | 367 |
qq|CREATE USER "$form->{db}" DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP IDENTIFIED BY "$form->{db}"| |
362 | 368 |
); |
363 | 369 |
|
364 |
$dbcreate{Pg} .= " WITH ENCODING = '$form->{encoding}'" if $form->{encoding}; |
|
370 |
my %dboptions = ( |
|
371 |
'Pg' => [], |
|
372 |
); |
|
373 |
|
|
374 |
push(@{$dboptions{"Pg"}}, "ENCODING = " . $dbh->quote($form->{"encoding"})) |
|
375 |
if ($form->{"encoding"}); |
|
376 |
if ($form->{"dbdefault"}) { |
|
377 |
my $dbdefault = $form->{"dbdefault"}; |
|
378 |
$dbdefault =~ s/[^a-zA-Z0-9_\-]//g; |
|
379 |
push(@{$dboptions{"Pg"}}, "TEMPLATE = $dbdefault"); |
|
380 |
} |
|
365 | 381 |
|
366 |
$form->{sid} = $form->{dbdefault}; |
|
367 |
&dbconnect_vars($form, $form->{dbdefault}); |
|
368 |
my $dbh = |
|
369 |
DBI->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}) |
|
370 |
or $form->dberror; |
|
371 | 382 |
my $query = qq|$dbcreate{$form->{dbdriver}}|; |
383 |
$query .= " WITH " . join(" ", @{$dboptions{"Pg"}}) if (@{$dboptions{"Pg"}}); |
|
384 |
|
|
372 | 385 |
$dbh->do($query) || $form->dberror($query); |
373 | 386 |
|
374 | 387 |
if ($form->{dbdriver} eq 'Oracle') { |
Auch abrufbar als: Unified diff
Beim Anlegen einer Datenbank die bei "Als Vorlage verwenden" eingetragene Datenbank auch wirklich als Vorlage verwenden.