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

Mikhael Goikhman migo at homemail.com
Sat Mar 13 09:49:35 PST 2004

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'};


perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'

More information about the Perl mailing list