From: Jess Robinson Date: Sat, 14 Oct 2006 20:21:26 +0000 (+0000) Subject: Add find_or_new / in_storage example X-Git-Tag: v0.07003~25 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9e4c2514bdb78f7011e7af60de95e9ec6f1661c3;p=dbsrgits%2FDBIx-Class.git Add find_or_new / in_storage example --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index f2934cb..2377fc5 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -1136,5 +1136,14 @@ C: } } -=cut +=head2 Want to know if find_or_create found or created a row? + +Just use C instead, then check C: + my $obj = $rs->find_or_new({ blah => 'blarg' }); + unless ($obj->in_storage) { + $obj->insert; + # do whatever else you wanted if it was a new row + } + +=cut