broquaint has asked for the wisdom of the Perl Monks concerning the following question:
From the documentation and the code it isn't apparent that this is already implemented, or is this perhaps a misuse of Class::DBI?Class::DBI::mysql->set_sql('lastid', 'SELECT LAST_INSERT_ID()'); ## hacked from the Class::DBI::mysql methods sub Class::DBI::mysql::id { my $class = ref $_[0] || $_[0]; my $sth; eval { $sth = $class->sql_lastid(); $sth->execute(); }; if($@) { $class->DBIwarn("lastid"); return; } my $id = $sth->fetch->[0]; $sth->finish(); return $id; }
_________
broquaint
update (me): title change (was Getting the latest id with Class::DBI)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting last MySQL id with Class::DBI
by bart (Canon) on May 19, 2003 at 11:42 UTC | |
|
Re:Getting last MySQL id with Class::DBI
by edoc (Chaplain) on May 19, 2003 at 17:07 UTC | |
|
Re: Getting last MySQL id with Class::DBI
by Phaysis (Pilgrim) on May 20, 2003 at 14:02 UTC | |
|
Re: Getting last MySQL id with Class::DBI
by awgibbs (Initiate) on May 19, 2003 at 15:50 UTC | |
by broquaint (Abbot) on May 19, 2003 at 15:59 UTC |