[Dbix-class] No-lurking First Post
Roderick A. Anderson
raanders at acm.org
Mon Sep 25 20:56:17 CEST 2006
Daniel Westermann-Clark wrote:
> On 2006-09-25 10:47:05 -0700, Roderick A. Anderson wrote:
>
>>But if the case is the record already exists ( find_ ) I don't need a
>>call to rebuild a list but if it doesn't exist ( _create ) I need to
>>make the call.
>>
>>The POD says it returns the $obj. Is there elegant way to determine
>>if it is a found or created object? If not, does it make sense to
>>have the something_or_otherthing methods also return which of the
>>two happened?
>
>
> Sounds like you want find_or_new, followed by an in_storage check:
>
> my $obj = $rs->find_or_new({ blah => 'blarg' });
> unless ($obj->in_storage) {
> $obj->insert;
> # rebuild list
> # yay!
> }
Wow!!!
I just re-read the POD and there it was and the most embarrassing part
is I actually read it thought about it but it didn't click.
Thanks.
Rod
--
>
More information about the Dbix-class
mailing list