At 12:00 AM -0500 2000-01-13, Jamie Le Tual wrote:
>the first thing you do after the execute for the insert is
>
>my $id = $sth->{insertid};
>
>I think there used to be a way to do it through the $dbh ref but I
>remember reading somewhere that that was deprecated; but I can't find that
>reference. Anyways, I just tried the example above to be sure it works,
>and it does.
Actually, it's the other way around. The $sth->{insertid} form (based
on the statement handle) is the deprecated form. The newer form
$dbh->{mysql_insertid} (based on the database handle) is the preferred
form now. Older versions of DBD::mysql do not have the latter form,
though.
I think I misspelled that form as $dbh->{mysql_insert_id} in my
previous message. Sorry.
>On Wed, 12 Jan 2000, jim@work wrote:
>
>->
>->ok, i'm sure i have missed this in previous discussions, and it seems so
>->elemetary (uh, ya) that i must have overlooked it in the manual (albeit,
>->it's huge).
>->
>->when i insert a record into the database from PERL (using DBI), that has an
>->auto-increment primary key, how do i got about getting that
>primary key value??
>->
>->currently, i set a value in the record to something i am pretty sure will
>->be unique, then query looking for that value, but that is certainly not
>->foolproof. so any help would be appreciated.
--
Paul DuBois, paul@stripped