use the passed-in parameters to either update or create a new record. In my situation, my %params are used by several classes, therefore it contains more keys than the columns of any individual class. When I passed it in the above two methods, I get the "no such column" error. My question is what is the best way to allow this. I did the following (I used a different method name), which constructs another param with keys coming from the columns(). I didn't like this since it relies on knowing something about how the parameters get translated to column names, and it might not work well when access/mutator names get changed. Is there a better way? Thanks.set(%params); create(\%params);
sub set_all{ my($self, %params) = @_; my %p =(); # construct a new param foreach my $c ($self->columns()){ my $normalize = lc $c; # seems internally always lower case $p{$normlize} = $params{$normalize} if $params{$normalize}; } $self->set(%p); # call the original set }
In reply to How to tell Class::DBI to ignore some parameters by johnnywang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |