Changeset 787 for trunk


Ignore:
Timestamp:
08/23/19 15:24:59 (5 years ago)
Author:
Kris Deugau
Message:

/trunk

Commit longstanding refinement of getZonesByCIDR()

  • improved sub header docucomment
  • add sorting, with fallback to "whatever the database spits out" if the caller doesn't send literal ASC or DESC
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r786 r787  
    54975497## DNSDB::getZonesByCIDR()
    54985498# Get a list of zone names and IDs that records for a passed CIDR block are within.
    5499 # Optionally restrict to a specific location/view
    5500 # Optionally leave off the default_location field
     5499# Arguments must be passed in a hash
     5500# Requires an argument "cidr" for the CIDR block to find parent/child zone(s) for
     5501# Accepts optional arguments:
     5502# - return_location:  Flag indicating whether to return default_location or not
     5503# - location: Restrict matches to a particular location/view
     5504# - sort:  Valid values are ASC or DESC;  if omitted or set to something else
     5505#   results will be "whatever the database returns"
    55015506sub getZonesByCIDR {
    55025507  my $self = shift;
     
    55085513        " FROM revzones WHERE (revnet >>= ? OR revnet <<= ?)".
    55095514        (defined($args{location}) ? " AND default_location = ?" : '');
     5515  if ($args{sort}) {
     5516    if ($args{sort} eq 'ASC' || $args{sort} eq 'DESC') {
     5517      $sql .= " ORDER BY revnet $args{sort}";
     5518    }
     5519  }
    55105520  my @svals = ($args{cidr}, $args{cidr});
    55115521  push @svals, $args{location} if defined $args{location};
Note: See TracChangeset for help on using the changeset viewer.