DbZoneRepository
class DbZoneRepository implements ZoneRepositoryInterface (View source)
SQL zone repository over the PowerDNS domains and records tables plus the zones and zones_groups ownership tables.
Methods
No description
Get reverse zones with efficient database-level filtering and pagination
Count the zones a permission scope may see, optionally narrowed by first letter and zone kind.
Get all reverse zone counts in a single query (optimization)
Get a complete list of zones accessible by the current user
Get a zone by ID with full details
Find forward zones associated with reverse zones through PTR records
Get zone comment by zone ID
Write the native zones row of a zone the backend has just created.
Drop the native zones row of a zone, when the zone is deleted.
Set the zone comment, creating the zones row for a zone that has none.
Update zone comment
Get users who own a zone
Lock the zone's owner rows for the rest of the open transaction, so a concurrent removal waits instead of deciding on stale owner counts.
Direct owners of several zones in one query, for list pages.
Ids of every zone the user owns directly or through a group, in the id space the zone logs and zones_groups use.
Add owner to zone
Remove owner from zone
Whether two zones share this zone id in API backend mode, so owner rows and group grants keyed by it cannot tell the zones apart and are not honoured.
Give the named zone row a user being deleted holds to another user, so the zone stays.
Check if user is already an owner of the zone
Delete a zone by ID
Update zone metadata
Get the total number of zones
Get count of zones filtered by zone IDs (permission-aware)
Get all zones filtered by zone IDs (permission-aware)
Get a zone by ID
Details
__construct($db, $config, DnsBackendProviderInterface|null $backendProvider = null)
No description
array
getDistinctStartingLetters(int $userId, bool $viewOthers)
No description
ZoneSummary>|int
getReverseZones(string $permType, int $userId, string $reverseType = 'all', int $offset = 0, int $limit = 25, string $sortBy = 'name', string $sortDirection = 'ASC', bool $countOnly = false, bool $showSerial = false, bool $showTemplate = false, bool $includeHealth = true, bool $includeRecordCount = true)
Get reverse zones with efficient database-level filtering and pagination
int
countZones(string $permType, int|null $userId, string $letterStart = 'all', string $zoneType = 'forward')
Count the zones a permission scope may see, optionally narrowed by first letter and zone kind.
array
getReverseZoneCounts(string $permType, int $userId)
Get all reverse zone counts in a single query (optimization)
array
listZones(int|null $userId = null, bool $viewOthers = false, array $filters = [], int $offset = 0, int $limit = 100)
Get a complete list of zones accessible by the current user
ZoneDetail|null
getZone(int $zoneId)
Get a zone by ID with full details
The getZoneById() core plus comment, secured and the owner list; ZoneDetail::toArray() gives the legacy column-keyed shape.
array
findForwardZonesByPtrRecords(array $reverseZoneIds)
Find forward zones associated with reverse zones through PTR records
Optimized 3-step approach instead of slow LIKE JOIN:
- Fetch all PTR records for reverse zones
- Extract domain suffixes from PTR content in PHP
- Look up forward zones with exact IN() match (uses indexes)
string|null
getZoneComment(int $zoneId)
Get zone comment by zone ID
int|string
createZoneShell(int $domainId, int|null $owner, int $templateId)
Write the native zones row of a zone the backend has just created.
void
deleteZoneShell(int $domainId)
Drop the native zones row of a zone, when the zone is deleted.
void
saveZoneComment(int $zoneId, string $comment)
Set the zone comment, creating the zones row for a zone that has none.
bool
updateZoneComment(int $zoneId, string $comment)
Update zone comment
array
getZoneOwners(int $zoneId)
Get users who own a zone
void
lockZoneOwners(int $zoneId)
Lock the zone's owner rows for the rest of the open transaction, so a concurrent removal waits instead of deciding on stale owner counts.
array
getOwnerIdsByZoneIds(array $zoneIds)
Direct owners of several zones in one query, for list pages.
array
getOwnedZoneIds(int $userId)
Ids of every zone the user owns directly or through a group, in the id space the zone logs and zones_groups use.
bool
addOwnerToZone(int $zoneId, int $userId)
Add owner to zone
bool
removeOwnerFromZone(int $zoneId, int $userId)
Remove owner from zone
bool
isSharedZoneId(int $zoneId)
Whether two zones share this zone id in API backend mode, so owner rows and group grants keyed by it cannot tell the zones apart and are not honoured.
bool|null
handOverNamedZoneRow(int $zoneId, int $fromUserId, int $toUserId)
Give the named zone row a user being deleted holds to another user, so the zone stays.
Null when the backend keeps no such row or the user holds none (add an owner instead); false when the id is shared and the row it opens is not that user's.
bool
isUserZoneOwner(int $zoneId, int $userId)
Check if user is already an owner of the zone
bool
deleteZone(int $zoneId)
Delete a zone by ID
bool
updateZone(int $zoneId, array $updates)
Update zone metadata
int
getZoneCount()
Get the total number of zones
int
getZoneCountFiltered(array|null $zoneIds, int|null $userId = null, string|null $nameFilter = null, string|null $nameContains = null)
Get count of zones filtered by zone IDs (permission-aware)
array
getAllZonesFiltered(array|null $zoneIds, int|null $userId = null, string|null $nameFilter = null, int|null $offset = null, int|null $limit = null, string|null $nameContains = null, array $sort = [])
Get all zones filtered by zone IDs (permission-aware)
array|null
getZoneById(int $zoneId)
Get a zone by ID