Updating lots of database fields in a single row

Mark Overmeer mark at overmeer.net
Wed Jan 23 09:52:15 GMT 2013


* Ruud H.G. van Tol (rvtol at isolution.nl) [130123 09:45]:
> On 2013-01-23 10:27, William Blunn wrote:
> 
> >my @fields_to_update = grep { $hash->{$_} } @fields;
> 
> Be aware that it skips any false value, like undef, '', '0', 0.

  my @fields_to_update = grep defined $hash->{$_}, @fields;

But that's is probably not true either: after the $hash was read
from the database, logic may have cleared some of these fields.
The clearing itself usually needs to be moved into the database
as well... undef fields need to be set to NULL.
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net



More information about the london.pm mailing list