@ISA = qw(Exporter);
@EXPORT = qw(
&get_verlagsliste
+ &save_verlag
);
#%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
#-----------------------------------------------------------------------------------
+=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 = <<ENDE;
+INSERT INTO `verlage` (
+ `id`, `name_short`, `name_long` )
+ VALUES (
+ ?, ?, ? )
+ ON DUPLICATE KEY UPDATE
+ `id` = LAST_INSERT_ID(`id`), `name_short` = ?, `name_long` = ?
+ENDE
+
+ if ( $storage->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