rogueFalcon has asked for the wisdom of the Perl Monks concerning the following question:
-- rogueFalconsub InsertProspect { # Get the new prospect my $prospect = shift; # Connect to the database my $dbh = DBI->connect('DBI:mysql:menagerie', 'menagerie') or die +"Couldn't connect to database: " . DBI->errstr; # Set all of the variables that we need to pass to MySQL my $name = $prospect->name; my $address = $prospect->address; my $address2 = $prospect->address2; my $state = $prospect->state; my $city = $prospect->city; my $phone = $prospect->phone; my $phone2 = $prospect->phone2; my $phone3 = $prospect->phone3; my $phone4 = $prospect->phone4; my $phoneType = $prospect->phone; my $phone2Type = $prospect->phone2; my $phone3Type = $prospect->phone3; my $phone4Type = $prospect->phone4; my $email = $prospect->email; my $url = $prospect->url; my $interestLevel = $prospect->interestLevel; my $designFirm = $prospect->designFirm; my $hostingFirm = $prospect->hostingFirm; my $companyName = $prospect->companyName; # Insert the new prospect in the database my $sth = $dbh->prepare("INSERT INTO prospect VALUES (NULL, \"$nam +e\", \"$address\", \"$address2\", \"$state\", \"$city\", \"$phone\", +\"$phone2\", \"$phone3\", \"$phone4\", \"$phoneType\", \"$phone2Type\ +", \"$phone3Typ +e\", \"$phone4Type\", \"$email\", \"$url\", \"$interestLevel\", \"$de +signFirm\", \"$hostingFi +rm\", \"$companyName\")"); # Execute the statement $sth->execute or die print DBI->errstr; # Lets get the prospect id that we just added back $sth = $dbh->prepare("SELECT last_insert_id() from prospect"); $sth->execute or die print DBI->errstr; my @id = $sth->fetchrow_array; my $ID = $id[[0]]; # Return the new prospects ID return $ID; } I want to be good... really I do. I just don't know how :-)<p>
Why do you people insist on doing things sdrawkcab?
Edit by tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MySQL / DBI / OOP
by runrig (Abbot) on Sep 05, 2001 at 23:48 UTC | |
|
(Ovid) Re: MySQL / DBI / OOP
by Ovid (Cardinal) on Sep 06, 2001 at 00:26 UTC | |
|
Re: MySQL / DBI / OOP
by blakem (Monsignor) on Sep 05, 2001 at 23:47 UTC | |
|
Re: MySQL / DBI / OOP
by princepawn (Parson) on Sep 05, 2001 at 23:45 UTC | |
|
Re: MySQL / DBI / OOP
by mr.dunstan (Monk) on Sep 05, 2001 at 23:49 UTC | |
|
Re: MySQL / DBI / OOP
by lachoy (Parson) on Sep 06, 2001 at 07:57 UTC | |
by rogueFalcon (Beadle) on Dec 09, 2001 at 03:52 UTC | |
|
Re (tilly) 1: MySQL / DBI / OOP
by tilly (Archbishop) on Dec 10, 2001 at 10:38 UTC |