'is_auto_increment' => 1,
'extras' => { 'unsigned' => 1 },
},
- "unit_name" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 },
- "unit_name_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 },
- "unit_plural" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 },
- "unit_plural_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 },
- "unit_type_id" => { 'data_type' => "INT", 'default_value' => '0', 'is_nullable' => 0, 'size' => 10, 'extras' => { 'unsigned' => 1 } },
- "date_created" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 },
- "date_changed" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 },
+ "unit_name" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 },
+ "unit_name_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 },
+ "unit_plural" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 50 },
+ "unit_plural_abbrev" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 20 },
+ "unit_type_id" => { 'data_type' => "INT", 'default_value' => '0', 'is_nullable' => 0, 'size' => 10, 'extras' => { 'unsigned' => 1 } },
+ "date_created" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 },
+ "date_changed" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 },
);
__PACKAGE__->set_primary_key("unit_id");
__PACKAGE__->add_unique_constraint( "unit_name", ["unit_name"] );
-
-__PACKAGE__->belongs_to( 'unit_type' => 'CookBook::Db::UnitTypes', 'unit_type_id', );
-
+__PACKAGE__->belongs_to( 'unit_type' => 'CookBook::Db::UnitTypes', 'unit_type_id', );
#----------------------------------------------------------------------------------------
);
my @import_tables = qw(
- authors
- yield_types
- units
- ingredients
- ingredient_groups
- recipes
- recipe_authors
- recipe_ingredients
+ authors
+ yield_types
+ units
+ ingredients
+ ingredient_groups
+ recipes
+ recipe_authors
+ recipe_ingredients
);
my %import_method = (
- 'authors' => \&import_author_table,
- 'yield_types' => \&import_yield_types_table,
- 'units' => \&import_units_table,
- 'ingredients' => \&import_ingredients_table,
- 'ingredient_groups' => \&import_ingredient_groups_table,
- 'recipes' => \&import_recipes_table,
- 'recipe_authors' => \&import_recipe_authors_table,
- 'recipe_ingredients' => \&import_recipe_ingredients_table,
+ 'authors' => \&import_author_table,
+ 'yield_types' => \&import_yield_types_table,
+ 'units' => \&import_units_table,
+ 'ingredients' => \&import_ingredients_table,
+ 'ingredient_groups' => \&import_ingredient_groups_table,
+ 'recipes' => \&import_recipes_table,
+ 'recipe_authors' => \&import_recipe_authors_table,
+ 'recipe_ingredients' => \&import_recipe_ingredients_table,
);
my $admin_data = {
return undef;
}
print ok() . "\n";
- } ## end for my $table (@target_tables)
+ } ## end for my $table (@import_tables)
print "\n";
return 1;
return undef unless $target_dbh->do($sql);
return 1;
-} ## end sub create_recipe_authors_table
+} ## end sub create_ingredients_table
#-------------------------------------------------------------
$map_ingredient_id{ $ingr->{'id'} } = $target_dbh->{'mysql_insertid'};
- }
+ } ## end while ( $ingr = $source_sth->fetchrow_hashref...
return 1;
-} ## end sub import_receipes_table
+} ## end sub import_ingredients_table
#-------------------------------------------------------------
return undef unless $target_dbh->do($sql);
return 1;
-} ## end sub create_recipe_authors_table
+} ## end sub create_ingredient_groups_table
#-------------------------------------------------------------
return undef;
}
- }
+ } ## end while ( $ingr = $source_sth->fetchrow_hashref...
return 1;
-} ## end sub import_receipes_table
+} ## end sub import_ingredient_groups_table
#-------------------------------------------------------------
while ( $row = $source_sth->fetchrow_hashref() ) {
if ( $old_rid != $row->{'recipe_id'} ) {
- $i = 1;
+ $i = 1;
$old_rid = $row->{'recipe_id'};
}
else {
return undef unless $target_dbh->do($sql);
return 1;
-} ## end sub create_recipe_authors_table
+} ## end sub create_recipe_ingredients_table
#-------------------------------------------------------------
while ( $row = $source_sth->fetchrow_hashref() ) {
if ( $old_rid != $row->{'recipe_id'} ) {
- $i = 1;
+ $i = 1;
$old_rid = $row->{'recipe_id'};
}
else {
push @$qparams, ( $row->{'ingredient_id'} and $row->{'ingredient_id'} > 0 ) ? $map_ingredient_id{ $row->{'ingredient_id'} } : undef;
push @$qparams, $row->{'amount'};
push @$qparams, $row->{'amount_offset'} || undef;
- push @$qparams, ( $row->{'unit_id'} and $row->{'unit_id'} > 0 ) ? $map_unit_id{$row->{'unit_id'}} : undef;
+ push @$qparams, ( $row->{'unit_id'} and $row->{'unit_id'} > 0 ) ? $map_unit_id{ $row->{'unit_id'} } : undef;
push @$qparams, $i;
push @$qparams, ( ( $row->{'group_id'} and $row->{'group_id'} > 0 ) ? $row->{'group_id'} : undef );
-
+
#$qparams = [ $map_recipe_id{ $row->{'recipe_id'} }, $map_author_id{ $row->{'author_id'} }, $i, ];
unless ( $target_dbh->do( $sql, {}, @$qparams ) ) {
return 1;
-} ## end sub import_recipe_authors_table
+} ## end sub import_recipe_ingredients_table
#-------------------------------------------------------------
return 1;
-}
+} ## end sub create_units_table
#-------------------------------------------------------------
$map_unit_id{ $row->{'id'} } = $target_dbh->{'mysql_insertid'};
- }
+ } ## end while ( $row = $source_sth->fetchrow_hashref(...
return 1;
-}
+} ## end sub import_units_table
#-------------------------------------------------------------
)
END_SQL
- for my $unit ( @Units ) {
+ for my $unit (@Units) {
$i++;
$qparams = [ $i, $unit ];
return undef;
}
- }
+ } ## end for my $unit (@Units)
return 1;
-} ## end sub create_yield_types_table
+} ## end sub create_unit_types_table
#-------------------------------------------------------------