From: Frank Brehm Date: Sun, 7 Oct 2007 14:28:15 +0000 (+0000) Subject: Tabelle 'unit_conversations' importiert X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=f5cdd1b6f645a791597dbcb2a93d6abdafb2fa7e;p=cookbook.git Tabelle 'unit_conversations' importiert git-svn-id: http://svn.brehm-online.com/svn/cookbook/trunk@26 191103c4-1d37-0410-b3e5-d8c2315c0aac --- diff --git a/sbin/initial_import.pl b/sbin/initial_import.pl index f4f00b0..5655e7b 100755 --- a/sbin/initial_import.pl +++ b/sbin/initial_import.pl @@ -36,6 +36,7 @@ my @target_tables = qw( yield_types unit_types units + unit_conversations properties prep_methods categories @@ -70,12 +71,14 @@ my %create_method = ( 'prep_methods' => \&create_prep_methods_table, 'ingredient_prep_methods' => \&create_ingredient_prep_methods_table, 'ingredient_weights' => \&create_ingredient_weights_table, + 'unit_conversations' => \&create_unit_conversations_table, ); my @import_tables = qw( authors yield_types units + unit_conversations categories properties prep_methods @@ -96,6 +99,7 @@ my %import_method = ( 'recipe_categories' => \&import_recipe_categories_table, 'yield_types' => \&import_yield_types_table, 'units' => \&import_units_table, + 'unit_conversations' => \&import_unit_conversations_table, 'ingredients' => \&import_ingredients_table, 'ingredient_groups' => \&import_ingredient_groups_table, 'ingredient_properties' => \&import_ingredient_properties_table, @@ -581,6 +585,84 @@ sub import_author_table { #------------------------------------------------------------- +=head2 create_unit_conversations_table( ) + +=cut + +sub create_unit_conversations_table { + + my $sql = <do($sql); + return 1; + +} ## end sub create_categories_table + +#------------------------------------------------------------- + +=head2 import_unit_conversations_table( ) + +=cut + +sub import_unit_conversations_table { + + my $sql = <prepare($sql) ) { + return undef; + } + + return undef unless $source_sth->execute(); + + $sql = <prepare($sql); + unless ($target_sth) { + $source_sth->finish(); + return undef; + } + + while ( $conv = $source_sth->fetchrow_hashref() ) { + + next unless $map_unit_id{ $conv->{'unit1_id'} } and $map_unit_id{ $conv->{'unit2_id'} }; + + $qparams = []; + push @$qparams, $map_unit_id{ $conv->{'unit1_id'} }; + push @$qparams, $map_unit_id{ $conv->{'unit2_id'} }; + push @$qparams, $conv->{'ratio'}; + + unless ( $target_dbh->do( $sql, {}, @$qparams ) ) { + $source_sth->finish(); + return undef; + } + + } ## end while ( $cat = $source_sth->fetchrow_hashref(... + + return 1; + +} ## end sub import_categories_table + +#------------------------------------------------------------- + =head2 create_categories_table( ) =cut