Re: using find_or_create in add_to_
[prev]
[thread]
[next]
[Date index for 2005/02/03]
On Thu, 2005-02-03 at 15:28 +0000, Dave Howorth wrote:
> Now I've come across a case where I want to use add_to_*, like
> $obj->add_to_a_related_table({ some => values })
>
> Now C-DBI-R-HasMany::_method_add_to calls create() so that's not what I
> want. Has anybody got a neat way of dealing with this situation?
I'd say just write your own. Here's an untested sketch:
sub add_or_associate_to_cds {
my ($self, $data) = @_;
my $cd = Music::CD->find_or_create( $data );
$cd->artist( $self->id() );
$cd->update();
};
- Perrin
 |
 |
Re: using find_or_create in add_to_
Perrin Harkins 17:23 on 03 Feb 2005
|