=item $self->add_manufacturer( %args ); Adds a manufacturer to the database. Required keys in %args: company_id company_name address city state zip contact phone fax email account_number Returns the new manufacturer id. =cut sub add_manufacturer { my ( $self, %args ) = @_; # make sure we have all required keys my @cols = qw( company_id company_name address city state zip contact phone fax email account_number ); if ( my @missing = grep { ! exists $args{$_} } @cols ) { die "add_manufacturer: missing args @missing"; } # build up the SQL. to make more efficient, do # this only once and stash it somewhere. my $cols = join ',', ( 'id', cols ); my $places = join ',', ( '?' ) x ( 1 + @cols ); my $sql = "INSERT INTO sf_manufacturers ( $cols )" . " VALUES ( $places )"; # do the actual insertion here. $self->{dbh}->do( $sql, {}, undef, @args{@cols} ); # still need to get actual new id here... return $self->{dbh}->get_latest_insert_id(); }