diff options
author | Mark Wells <mark@freeside.biz> | 2015-01-13 22:13:32 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-01-13 22:13:32 -0800 |
commit | 5368af2d6f297955475b4fe753cc038df2d1a584 (patch) | |
tree | 038152f89e2341b493b41a989d5139f82da1b88a /FS/FS/Record.pm | |
parent | 092990ee23947a1f7e893a72f38ce8923ca3b8ea (diff) |
voip.ms CDR import, #31835
Diffstat (limited to 'FS/FS/Record.pm')
-rw-r--r-- | FS/FS/Record.pm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 781230f..25e61d0 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -3336,6 +3336,22 @@ sub count { $self->scalar_sql($sql, @_); } +=item row_exists [ WHERE [, PLACEHOLDER ...] ] + +Convenience method for the common case of "SELECT 1 FROM table ... LIMIT 1" +with optional (but almost always needed) WHERE. + +=cut + +sub row_exists { + my($self, $where) = (shift, shift); + my $table = $self->table or die 'row_exists called on object of class '.ref($self); + my $sql = "SELECT 1 FROM $table"; + $sql .= " WHERE $where" if $where; + $sql .= " LIMIT 1"; + $self->scalar_sql($sql, @_); +} + =back =head1 SUBROUTINES |