[CDBI] delete from lookup table

Peter Speltz peterspeltz at gmail.com
Thu Oct 27 10:22:45 BST 2005


On 10/27/05, WulfDirk.Leuschner at sanofi-aventis.com
<WulfDirk.Leuschner at sanofi-aventis.com> wrote:
>
>
> > Peter Speltz [peterspeltz at gmail.com] wrote:
> >  What i have seen a lot is  is the use or "delete_all" on the results
> >  from a search.
> >  $class->search( id => $related_id)->delete_all;
>
> >  and if a "my_method" is a has_many accessor i think you can say;
> >  $self->my_method(id => $id)->delete_all;
>
> Unfortunately this does not work - it returns the mapped objects themselves.
> Thus, using
> this code you end up deleting both the entry in your lookup table *and* the
> the record for
> the mapped object.

I see what you mean now how the mapping messis everything up.
Seems CDBI should have a revove_from* method in this case. Should not
be too hard to write.




More information about the ClassDBI mailing list