class ReverseDomainHierarchySorting (View source)

Class ReverseDomainHierarchySorting

Provides hierarchical sorting for reverse DNS zones based on network structure. This class creates a sorting order that organizes reverse zones by their network hierarchy, grouping all zones related to the same network together and sorting them logically.

Methods

string
getHierarchicalSortOrder(string $field, string $dbType, string $direction = 'ASC')

Get hierarchy-based sort order SQL clause for reverse DNS zones.

array
sortDomainsHierarchically(array $domains)

PHP-based hierarchical sorting for reverse DNS zones.

Details

string getHierarchicalSortOrder(string $field, string $dbType, string $direction = 'ASC')

Get hierarchy-based sort order SQL clause for reverse DNS zones.

Sorts domains by extracting and comparing their components in hierarchical order, grouping zones by primary networks (e.g., 10.in-addr.arpa, 172.in-addr.arpa, 192.168.in-addr.arpa) and then sorting by subnet specificity within each network.

Parameters

string $field

The full field name to sort (e.g., "table.name")

string $dbType

The database type ('mysql', 'mysqli', 'pgsql', 'sqlite')

string $direction

Sort direction ('ASC' or 'DESC')

Return Value

string

SQL ORDER BY clause for hierarchical sorting

array sortDomainsHierarchically(array $domains)

PHP-based hierarchical sorting for reverse DNS zones.

Use this method when database sorting is not available.

Parameters

array $domains

Array of domain names to sort

Return Value

array

Sorted array of domain names