Zecho has asked for the wisdom of the Perl Monks concerning the following question:
Ok, DBI & MySQL are kickin my butt right now, I've read what tutorials and documentation I could find (and those pointed out to me in the CB) and am really looking for a simple solution for this. Someone please tell me there's a cleaner/easier way to simply add a row to the table.
What I've hacked together so far:
## table customers #|Company #|FirstName #|LastName #|PhoneNumber #|Bill2Street #|Bill2City #|Bill2State #|Bill2Zip #|Ship2Street #|Ship2City #|Ship2State #|Ship2Zip ###### my $dbh = DBI->connect('DBI:mysql:advance') or die "Couldn't connect t +o database: " . DBI->errstr; sub add_customer{ my ($company, $firstname, $lastname, $phonenumber, $bill2street, $bill +2city, $bill2state, $bill2zip, $ship2street, $ship2city, $ship2state, + $ship2zip) = @_; my $sth = $dbh->do('INSERT INTO customers VALUES (?,?,?,?,?,?,?,?,?,?, +?,?)'); die "Couldn't add customer" unless defined $sth; $sth->execute($company, $firstname, $lastname, $phonenumber, $bill2str +eet, $bill2city, $bill2state, $bill2zip, $ship2street, $ship2city, $s +hip2state, $ship2zip); }
|
---|
Replies are listed 'Best First'. | |
---|---|
(Ovid) Re: Looking for a simpler DBI solution.
by Ovid (Cardinal) on Nov 01, 2001 at 23:42 UTC | |
by Fastolfe (Vicar) on Nov 02, 2001 at 03:04 UTC | |
by George_Sherston (Vicar) on Nov 02, 2001 at 16:46 UTC | |
Re: Looking for a simpler DBI solution.
by kwoff (Friar) on Nov 01, 2001 at 23:32 UTC | |
by kwoff (Friar) on Nov 01, 2001 at 23:40 UTC | |
by Hanamaki (Chaplain) on Nov 01, 2001 at 23:49 UTC | |
by kwoff (Friar) on Nov 04, 2001 at 05:20 UTC | |
Re: Looking for a simpler DBI solution.
by lo_tech (Scribe) on Nov 01, 2001 at 23:27 UTC | |
Re: Looking for a simpler DBI solution.
by Anonymous Monk on Nov 02, 2001 at 20:50 UTC |
Back to
Seekers of Perl Wisdom