X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=29e5322efac89b02db6ac618855b32463dab94ef;hb=947cba18ac25c794fe855f6e604e1c13029c85f3;hp=16520f409152ec02571577609f6e1aaafd79c535;hpb=39289cd1e5a06044aa9a8dc3d2e4d8c9ffb02b11;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 16520f409..29e5322ef 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -2589,6 +2589,20 @@ sub ut_enum { return "Illegal (enum) field $field: ". $self->getfield($field); } +=item ut_enumn COLUMN CHOICES_ARRAYREF + +Like ut_enum, except the null value is also allowed. + +=cut + +sub ut_enumn { + my( $self, $field, $choices ) = @_; + $self->getfield($field) + ? $self->ut_enum($field, $choices) + : ''; +} + + =item ut_foreign_key COLUMN FOREIGN_TABLE FOREIGN_COLUMN Check/untaint a foreign column key. Call a regular ut_ method (like ut_number) @@ -2895,7 +2909,8 @@ sub scalar_sql { my $sth = dbh->prepare($sql) or die dbh->errstr; $sth->execute(@_) or die "Unexpected error executing statement $sql: ". $sth->errstr; - my $scalar = $sth->fetchrow_arrayref->[0]; + my $row = $sth->fetchrow_arrayref or return ''; + my $scalar = $row->[0]; defined($scalar) ? $scalar : ''; }