[Dbix-class] No-lurking First Post

Roderick A. Anderson raanders at acm.org
Mon Sep 25 19:47:05 CEST 2006


Sorry to not lurk longer ( I just joined a few minutes ago ) and my 
search if the mail archives hasn't been fruitful so I'm going to do the 
newbie thing.

Using DBIx::Class via Catalyst I'm trying to optimize the number 
database calls.  Just because it's the right thing to do.

Currently the code I'm working on uses

	$c->model( 'TheModel' )->find_or_create( ... );

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?

My alternative will be to enclose a '->create' in an eval and test $@. 
Not a problem but magic is good.


TIA,
Rod
-- 



More information about the Dbix-class mailing list