[Catalyst] Getting the id from a resultset
Ash Berlin
ash_cpan at firemirror.com
Thu Oct 4 10:34:54 GMT 2007
Adeola Awoyemi wrote:
> 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.
Have you set_primary_key on that result source? Does the id column have
an is_auto_increment attribute?
(Also s/resultset/row/; and there is a dbix-class mailing list where
this would be better sent:
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class )
More information about the Catalyst
mailing list