diff options
author | mark <mark> | 2012-01-18 02:48:03 +0000 |
---|---|---|
committer | mark <mark> | 2012-01-18 02:48:03 +0000 |
commit | 5697bba078d6f9e263775bc2d887cc1ce3ff873d (patch) | |
tree | 2523653352b55604174c8c462089a685d567e9f5 /FS/FS/Record.pm | |
parent | 57fe641524a2e3057f577074b26ab75b24534bbc (diff) |
search services by tower/sector, #15950
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 598cb6a77..e4bc6c562 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -2802,6 +2802,22 @@ sub scalar_sql { defined($scalar) ? $scalar : ''; } +=item count [ WHERE ] + +Convenience method for the common case of "SELECT COUNT(*) FROM table", +with optional WHERE. Must be called as method on a class with an +associated table. + +=cut + +sub count { + my($self, $where) = (shift, shift); + my $table = $self->table or die 'count called on object of class '.ref($self); + my $sql = "SELECT COUNT(*) FROM $table"; + $sql .= " WHERE $where" if $where; + $self->scalar_sql($sql); +} + =back =head1 SUBROUTINES |