[CDBI] delete from lookup table

Bill Moseley moseley at hank.org
Thu Oct 27 13:44:27 BST 2005


On Thu, Oct 27, 2005 at 10:02:14AM +0200, WulfDirk.Leuschner at sanofi-aventis.com wrote:
> 
> The code snippet Bill provided (see below) does the right thing -
> and I did it more or less in the same but a non-generic way by
> providing an extra sub in my USER class.

What I posted was from my form handling code -- it's generic so it
will work with any class I'm updating with a form.  That same
meta_info method is also used to populate the form with options.

> The thing I do not really like about Bill's code is the need to dig
> into the object's hash structure - because there is no method
> available to retrieve the necessary information. I'd rather have a
> somewhat 'cleaner' way of deleting the mapping data.

That would be nice.  I'm using it meta_info so much in my code that
it now feels quite clean and natural...

I suspect other database object mappers provide this ability.



BTW - Looking at what I posted:


> >        # Grab the value from the form field
> >        my $value = $field->value;
> >
> >        # Figure out which values to keep:
> >
> >        my %keep = map { $_ => 1 } ref $value ? @$value : ( $value );

I suspect that should be more like:

           my %keep = map { $_ => 1 } ref $value ? @$value : ( $value )
               if defined $value;



-- 
Bill Moseley
moseley at hank.org





More information about the ClassDBI mailing list