From: Frank Brehm Date: Fri, 4 Apr 2008 14:14:08 +0000 (+0000) Subject: Mit Verlagen weitergemacht X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=116db9838d89af44ceeb2165640dddcdb87a4281;p=books.git Mit Verlagen weitergemacht --- diff --git a/lib/FrBr/Books/Util/Author.pm b/lib/FrBr/Books/Util/Author.pm index 4e2655c..de295ff 100644 --- a/lib/FrBr/Books/Util/Author.pm +++ b/lib/FrBr/Books/Util/Author.pm @@ -137,7 +137,7 @@ INSERT INTO `autoren` ( VALUES ( ?, ?, ? ) ON DUPLICATE KEY UPDATE - `autor_name` = ?, `autor_descr` = ? + `id` = LAST_INSERT_ID(`id`), `autor_name` = ?, `autor_descr` = ? ENDE if ( $storage->debug() ) { diff --git a/lib/FrBr/Books/Util/Verlag.pm b/lib/FrBr/Books/Util/Verlag.pm index 41e7d18..c6d306c 100644 --- a/lib/FrBr/Books/Util/Verlag.pm +++ b/lib/FrBr/Books/Util/Verlag.pm @@ -23,6 +23,7 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw( &get_verlagsliste + &save_verlag ); #%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], @@ -113,6 +114,51 @@ sub get_verlagsliste { #----------------------------------------------------------------------------------- +=head2 save_verlag( $c, $verlag ) + +=cut + +sub save_verlag { + + my $c = shift; + my $autor = shift; + my $K = __PACKAGE__ . "::save_verlag(): "; + + $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2; + + my $storage = $c->stash->{'storage'}; + + my $save_func = sub { + my ( $storage, $dbh, $verlags_id, $name_short, $name_long ) = @_; + $name_long = '' unless defined $name_long; + my $sql = <debug() ) { + my $text = $sql; + $text =~ s/\s+$//; + $text .= ": " . join( ", ", map { $dbh->quote($_) } ( $verlags_id, $name_short, $name_long, $name_short, $name_long ) ) . "\n"; + warn $text; + } + + my $sth = $dbh->prepare($sql); + $sth->execute( $verlags_id, $name_short, $name_long, $name_short, $name_long ); + }; + + $storage->dbh_do( $save_func, $verlag->{'id'}, $verlag->{'name'}, $verlag->{'desc'} ); + + return $storage->last_insert_id(); + +} + +#----------------------------------------------------------------------------------- + =head1 AUTHOR Frank Brehm