[Catalyst] Getting the id from a resultset

Adeola Awoyemi adeola at digitalcraftsmen.net
Thu Oct 4 10:15:20 GMT 2007


Hi all,

I'm using DBIx::Class and trying to get the 'id' back from a create() 
call but I get nothing.

I have something like:

     # db table also has an 'id' column which
     # is set to auto_increment.
     my $m = $c->model('MyAppDB::Foo');
     my $res = $m->create({
         name    => 'adeola',
         message => 'all for the sake of testing',
     });
     $c->log->debug("# ID OF LAST INSERT: " . $res->id);

So, instead of getting an id, I get nothing, not even 'undef' or 
something like that. But the other fields (e.g. $m->name) returns what I 
expect.

How do I get the 'id' of the resultset back? Am I missing something?

Thanks for your help,
Adeola.






More information about the Catalyst mailing list