[Dbix-class] Add to object after find_or_new

Dermot paikkos at googlemail.com
Fri Mar 20 18:17:05 GMT 2009


Hi,

If you use find_or_new to check for the existence of a row, and it
return empty (in_storage is not set) can you add to the the object
before you insert? A bit like this:



  my $obj = $rs->find_or_new({ blah => 'blarg' });
  if ($obj->in_storage) {
    # do whatever else you wanted if it was a new row
  }
  else {

$obj->insert;
  }



More information about the DBIx-Class mailing list