[Israel.pm] DBI - MySQL - last_insert_id doesn't work?

semuel semuel at semuel.co.il
Sat Mar 13 14:24:33 PST 2004

Hello There.

That worked, thanks.
But what happened to last_insert_id?
I do remember relaying on it last time that I fooled with MySQL.
(well, a few years passed...)


-----Original Message-----
>From Mikhael Goikhman
Sent: Saturday, March 13, 2004 7:50 PM
To: Perl in Israel
Subject: Re: [Israel.pm] DBI - MySQL - last_insert_id doesn't work?

On 13 Mar 2004 18:57:41 +0200, semuel wrote:
> I'm working with mysql, and trying to get the last_insert_id right after I
> inserted a row to a table.
> But last_insert_id return undef.
> I checked the result of the $dbh->do command (inside it the INSERT command
> takes place) 
> And it returns 1. In the database the row saw inserted.
> Help?

It should be:

  my $ok = $dbh->do("insert ...");
  my $id = $dbh->{'mysql_insertid'};


More information about the Perl mailing list