Re: using find_or_create in add_to_
[prev]
[thread]
[next]
[Date index for 2005/02/03]
On Thu, Feb 03, 2005 at 03:28:57PM +0000, Dave Howorth wrote:
> In my application, I almost always want to do find_or_create instead of
> create. If there's already data in the database that matches the data I
> have, I want to refer to it, not create a duplicate record.
> So far, I've just been taking care to use find_or_create, and even
> overriding create to give me a warning if I forget :)
> 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?
sub My::Class::DBI::BaseClass;
use base 'Class::DBI';
*create = __PACKAGE__->can('find_or_create');
1;
Tony
|
|
Re: using find_or_create in add_to_
Tony Bowden 18:46 on 03 Feb 2005
|