interface DnsBackendProviderInterface implements ZoneWriteBackendInterface, ZoneReadBackendInterface, RecordWriteBackendInterface, RecordReadBackendInterface, SerialBackendInterface, SupermasterBackendInterface, CatalogBackendInterface, SearchBackendInterface, BackendCapabilitiesInterface (View source)

PowerDNS data access (domains, records, supermasters) over direct SQL or the PowerDNS API; Poweradmin-native tables stay on SQL.

Methods

int|false
createZone(string $domain, string $type, string $slaveMaster = '')

Create a new zone in the DNS backend.

bool
deleteZone(int $domainId, string $zoneName)

Delete a zone and all its associated DNS data (records, metadata, cryptokeys).

bool
updateZoneType(int $domainId, string $type)

Change zone type (NATIVE, MASTER, SLAVE, PRODUCER, CONSUMER).

bool
updateZoneMaster(int $domainId, string $masterIp)

Update slave zone's master IP address.

bool
retrieveZone(int $domainId)

Request an immediate AXFR transfer of a secondary (slave) zone from its master.

bool
notifyZone(int $domainId)

Queue a NOTIFY to the secondaries of a primary zone.

bool
updateZoneAccount(int $domainId, string $account)

Update zone account field.

bool
zoneExists(string $zoneName)

Check if a zone exists by name.

array|null
getZoneById(int $domainId)

Get zone info by ID.

string|null
getZoneNameById(int $domainId)

Get zone name by domain ID.

int|null
getZoneIdByName(string $zoneName)

Get zone ID by name.

string
getZoneTypeById(int $domainId)

Get zone type by domain ID.

string|null
getZoneMasterById(int $domainId)

Get zone master by domain ID, for any zone kind.

int
getBestMatchingReverseZoneId(string $reverseName)

Find the best matching reverse zone ID for a PTR record name.

array
getZones(bool $withDnssec = true)

Get all zones from the DNS backend.

array
getZonesByIds(array $domainIds)

Get id, name and type for the given zone ids, sorted by name.

int
countZones()

Count all zones in the DNS backend.

int|null
countRecords()

Count all record rows in the DNS backend, ENTs included.

int
countZoneRecords(int $domainId)

Count non-ENT records in a zone.

array
getZoneStats(bool $withDnssec = true)

Get bulk zone stats (DNSSEC state, SOA serials) keyed by zone name.

array|null
getZoneSoaHealth(string $zoneName, string $kind)

Report SOA-record presence and disabled state for a zone, used by zone-list UIs to render "Disabled" / "No SOA" badges. SLAVE zones legitimately have no SOA (records arrive via AXFR), so callers may pass the zone kind to skip unnecessary lookups; implementations must return is_missing_soa=false for SLAVE.

bool
addRecord(int $domainId, string $name, string $type, string $content, int $ttl, int $prio)

Add a DNS record.

int|string|null
addRecordGetId(int $domainId, string $name, string $type, string $content, int $ttl, int $prio, array|null $comment = null)

Add a DNS record and return its ID.

int|string|null
createRecordAtomic(int $domainId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled = 0, array|null $comment = null)

Create a DNS record atomically with optional disabled flag.

bool
editRecord(int|string $recordId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled, array|null $comment = null)

Edit an existing DNS record.

bool
deleteRecord(int|string $recordId)

Delete a DNS record by ID.

bool
replaceSoaContent(int $zoneId, string $content)

Replace the content of a zone's SOA record. The SQL backend keeps the stored TTL; the API backend rewrites the whole RRset with the configured dns.ttl.

bool
rewriteSoaContent(int $zoneId, callable $change)

Rewrites the zone's SOA content from its current value as one step, so concurrent writers to the zone cannot both bump from the same serial. The SQL backend locks the SOA row for it; the API backend reads and rewrites the RRset.

array|null
getRecordById(int|string $recordId)

Get a single record by ID.

int
getZoneIdFromRecordId(int|string $recordId)

Get zone ID from a record ID.

bool
recordExists(int $domainId, string $name, string $type, string $content)

Check if a record with given attributes exists.

array
getRecordsByZoneId(int $domainId, string|null $type = null)

Get records by zone ID, optionally filtered by type.

array
getRecordsByName(int $domainId, string $name, string|null $type = null)

Get the records at one name in a zone, optionally filtered by type.

array
findRecordsByName(string $name, string|null $type = null)

Find the records at one name across every zone, optionally filtered by type.

array
findRecordsByContent(string $content, string|null $type = null)

Find the records whose content equals the given value across every zone, optionally filtered by type. The API backend answers through the PowerDNS search endpoint, which stops at 10,000 matches; use findAllRecordsByContent() when a missed record would let a check pass.

array|null
findAllRecordsByContent(string $content, string|null $type = null)

findRecordsByContent(), or null when the backend could not see every match.

string
getSOARecord(int $domainId)

Get SOA record content for a zone.

array
getZoneRecords(int $domainId, string $zoneName)

Get all records for a zone from the DNS backend.

bool
hasSoaEditApi(int $domainId)

Check whether the zone has soa_edit_api configured in PowerDNS.

bool
setZoneSerialPolicy(int $domainId, string $zoneName, array $properties)

Set the zone's SOA serial policy metadata.

bool
addSupermaster(string $masterIp, string $nsName, string $account)

Add a supermaster (autoprimary).

bool
deleteSupermaster(string $masterIp, string $nsName)

Delete a supermaster (autoprimary).

array
getSupermasters()

Get all supermasters.

bool
updateSupermaster(string $oldMasterIp, string $oldNsName, string $newMasterIp, string $newNsName, string $account)

Update a supermaster.

array
getCatalogMembers(string $catalogName)

Zones carrying the given catalog.

array
getZonesByKind(string $kind)

Zones of one kind, with the catalog each currently belongs to.

string
getZoneCatalog(int $domainId)

Catalog the zone belongs to, lowercase and without a trailing dot, or '' when it is not a member.

bool
updateZoneCatalog(int $domainId, string $catalogName)

Join $catalogName, or leave the current catalog when it is ''.

array
searchDnsData(string $query, string $objectType = 'all', int $max = 100)

Search for zones and records matching a query.

bool
isApiBackend()

Check if this is the API backend.

bool
supportsLocalWriteTransaction()

Whether backend writes can be wrapped in a transaction on the Poweradmin database.

bool
recordIdsAreNumeric()

Whether record ids are the integer records.id values.

bool
managesSoaRecord()

Whether the backend writes and maintains the apex SOA of the zones it creates.

bool
allocatesZoneIdsLocally()

Whether zone ids are allocated from the local zones table rather than the PowerDNS domains table.

bool
providesSignedSerial()

Whether the zone list can carry the serial PowerDNS serves for signed zones.

bool
supportsRecordCountSort()

Whether zone lists can be ordered by record count across every page.

bool
supportsGroupSort()

Whether zone lists can be ordered by owning group.

bool
supportsZoneRetrieve()

Whether a secondary zone can be pulled from its primary on request.

bool
supportsZoneNotify()

Whether a primary zone can be told to send NOTIFY on request.

bool
syncsZoneListFromServer()

Whether the local zone list is a mirror that can be refreshed from the server.

Details

int|false createZone(string $domain, string $type, string $slaveMaster = '')

Create a new zone in the DNS backend.

Parameters

string $domain

Zone name (without trailing dot)

string $type

Zone type: NATIVE, MASTER, SLAVE, PRODUCER, or CONSUMER

string $slaveMaster

Master IP for kinds that replicate from a primary (SLAVE, CONSUMER)

Return Value

int|false

The new domain ID, or false on failure

bool deleteZone(int $domainId, string $zoneName)

Delete a zone and all its associated DNS data (records, metadata, cryptokeys).

Does NOT delete Poweradmin-internal data (zones table, records_zone_templ, etc.)

  • those are handled by the caller.

Parameters

int $domainId

Domain ID

string $zoneName

Zone name (needed for API calls)

Return Value

bool

bool updateZoneType(int $domainId, string $type)

Change zone type (NATIVE, MASTER, SLAVE, PRODUCER, CONSUMER).

Masters are cleared unless the new kind replicates from a primary.

Parameters

int $domainId

Domain ID

string $type

New zone type

Return Value

bool

bool updateZoneMaster(int $domainId, string $masterIp)

Update slave zone's master IP address.

Parameters

int $domainId

Domain ID

string $masterIp

Master IP address

Return Value

bool

bool retrieveZone(int $domainId)

Request an immediate AXFR transfer of a secondary (slave) zone from its master.

Needs a configured PowerDNS API. Without one the SQL backend returns false, since PowerDNS then pulls secondaries on its own refresh schedule.

Parameters

int $domainId

Domain ID

Return Value

bool

bool notifyZone(int $domainId)

Queue a NOTIFY to the secondaries of a primary zone.

Needs a configured PowerDNS API; without one the SQL backend returns false.

Parameters

int $domainId

Domain ID

Return Value

bool

bool updateZoneAccount(int $domainId, string $account)

Update zone account field.

Parameters

int $domainId

Domain ID

string $account

Account value

Return Value

bool

bool zoneExists(string $zoneName)

Check if a zone exists by name.

Parameters

string $zoneName

Zone name

Return Value

bool

array|null getZoneById(int $domainId)

Get zone info by ID.

Parameters

int $domainId

Domain ID

Return Value

array|null

[id, name, type, master, dnssec] or null

string|null getZoneNameById(int $domainId)

Get zone name by domain ID.

Parameters

int $domainId

Domain ID

Return Value

string|null

Zone name or null

int|null getZoneIdByName(string $zoneName)

Get zone ID by name.

Parameters

string $zoneName

Zone name

Return Value

int|null

Domain ID or null

string getZoneTypeById(int $domainId)

Get zone type by domain ID.

Parameters

int $domainId

Domain ID

Return Value

string

One of the ZoneKind values (NATIVE, MASTER, SLAVE, PRODUCER, CONSUMER); NATIVE when unknown

string|null getZoneMasterById(int $domainId)

Get zone master by domain ID, for any zone kind.

Parameters

int $domainId

Domain ID

Return Value

string|null

Master IP or null if none is stored

int getBestMatchingReverseZoneId(string $reverseName)

Find the best matching reverse zone ID for a PTR record name.

Parameters

string $reverseName

Reverse name (e.g. 1.168.192.in-addr.arpa)

Return Value

int

Zone ID or -1 if not found

array getZones(bool $withDnssec = true)

Get all zones from the DNS backend.

Returns raw zone data without Poweradmin metadata (ownership, comments). Each zone array contains: name, type, dnssec (bool), master (string).

Parameters

bool $withDnssec

Set false to skip DNSSEC state; API backends then avoid a per-zone lookup and report dnssec as false

Return Value

array

Array of zone data arrays

array getZonesByIds(array $domainIds)

Get id, name and type for the given zone ids, sorted by name.

Unknown ids are skipped.

Parameters

array $domainIds

Domain IDs

Return Value

array

int countZones()

Count all zones in the DNS backend.

Return Value

int

Zone count

int|null countRecords()

Count all record rows in the DNS backend, ENTs included.

Return Value

int|null

Record count, or null when the backend has no global count (API)

int countZoneRecords(int $domainId)

Count non-ENT records in a zone.

Parameters

int $domainId

Domain ID

Return Value

int

Record count

array getZoneStats(bool $withDnssec = true)

Get bulk zone stats (DNSSEC state, SOA serials) keyed by zone name.

SQL backends may return an empty array when this data is not needed; API backends fetch it in a single call to avoid N+1 lookups in zone lists. Record counts are not included - the PowerDNS zone list carries none.

Parameters

bool $withDnssec

Set false when neither the DNSSEC flag nor edited_serial is needed

Return Value

array

array|null getZoneSoaHealth(string $zoneName, string $kind)

Report SOA-record presence and disabled state for a zone, used by zone-list UIs to render "Disabled" / "No SOA" badges. SLAVE zones legitimately have no SOA (records arrive via AXFR), so callers may pass the zone kind to skip unnecessary lookups; implementations must return is_missing_soa=false for SLAVE.

Returns null on transient backend failure so callers can preserve any previously-cached state instead of overwriting it with an inferred default.

Parameters

string $zoneName

Zone name (without trailing dot)

string $kind

Zone kind ('MASTER', 'NATIVE', 'SLAVE', 'PRODUCER', 'CONSUMER')

Return Value

array|null

bool addRecord(int $domainId, string $name, string $type, string $content, int $ttl, int $prio)

Add a DNS record.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type (A, AAAA, CNAME, MX, etc.)

string $content

Record content

int $ttl Time-to-live
int $prio Priority

Return Value

bool

int|string|null addRecordGetId(int $domainId, string $name, string $type, string $content, int $ttl, int $prio, array|null $comment = null)

Add a DNS record and return its ID.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

int $ttl Time-to-live
int $prio Priority
array|null $comment

RRset comment ['content' => string, 'account' => string]; null leaves comments untouched. SQL mode ignores it.

Return Value

int|string|null

The new record ID (int for SQL mode, encoded string for API mode), or null on failure

int|string|null createRecordAtomic(int $domainId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled = 0, array|null $comment = null)

Create a DNS record atomically with optional disabled flag.

In SQL mode, wraps the INSERT in a transaction with deadlock retry. In API mode, one RRset REPLACE carries the record and the disabled flag.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

int $ttl Time-to-live
int $prio Priority
int $disabled

Disabled flag (0 = enabled, 1 = disabled)

array|null $comment

RRset comment as for addRecordGetId()

Return Value

int|string|null

The new record ID, or null on failure

bool editRecord(int|string $recordId, string $name, string $type, string $content, int $ttl, int $prio, int $disabled, array|null $comment = null)

Edit an existing DNS record.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

string $name

New record name

string $type

New record type

string $content

New record content

int $ttl

New TTL

int $prio

New priority

int $disabled

Whether record is disabled (0 or 1)

array|null $comment

RRset comment ['content' => string, 'account' => string]; null leaves comments untouched, empty content clears them. SQL mode ignores it.

Return Value

bool

bool deleteRecord(int|string $recordId)

Delete a DNS record by ID.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

bool

bool replaceSoaContent(int $zoneId, string $content)

Replace the content of a zone's SOA record. The SQL backend keeps the stored TTL; the API backend rewrites the whole RRset with the configured dns.ttl.

Parameters

int $zoneId

Domain ID

string $content

New SOA content

Return Value

bool

True when the SOA record was rewritten

bool rewriteSoaContent(int $zoneId, callable $change)

Rewrites the zone's SOA content from its current value as one step, so concurrent writers to the zone cannot both bump from the same serial. The SQL backend locks the SOA row for it; the API backend reads and rewrites the RRset.

Parameters

int $zoneId

Domain ID

callable $change

Gets the current content, returns the new content or null to keep it

Return Value

bool

False when the zone has no SOA record or the write failed

array|null getRecordById(int|string $recordId)

Get a single record by ID.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

array|null

Record data or null

int getZoneIdFromRecordId(int|string $recordId)

Get zone ID from a record ID.

Parameters

int|string $recordId

Record ID (int for SQL mode, encoded string for API mode)

Return Value

int

Zone ID (0 if not found)

bool recordExists(int $domainId, string $name, string $type, string $content)

Check if a record with given attributes exists.

Parameters

int $domainId

Domain ID

string $name

Record name

string $type

Record type

string $content

Record content

Return Value

bool

array getRecordsByZoneId(int $domainId, string|null $type = null)

Get records by zone ID, optionally filtered by type.

Parameters

int $domainId

Domain ID

string|null $type

Optional record type filter

Return Value

array

Array of record data

array getRecordsByName(int $domainId, string $name, string|null $type = null)

Get the records at one name in a zone, optionally filtered by type.

Names match case-insensitively, per RFC 4343.

Parameters

int $domainId

Domain ID

string $name

Record name, with or without a trailing dot

string|null $type

Optional record type filter

Return Value

array

Array of record data

array findRecordsByName(string $name, string|null $type = null)

Find the records at one name across every zone, optionally filtered by type.

Names match case-insensitively. The API backend reads the RRsets of the most specific zone that holds the name.

Parameters

string $name

Record name

string|null $type

Optional record type filter

Return Value

array

Array of record data (id, domain_id, name, type, content, ttl, prio, disabled)

array findRecordsByContent(string $content, string|null $type = null)

Find the records whose content equals the given value across every zone, optionally filtered by type. The API backend answers through the PowerDNS search endpoint, which stops at 10,000 matches; use findAllRecordsByContent() when a missed record would let a check pass.

Parameters

string $content

Record content, exact match

string|null $type

Optional record type filter

Return Value

array

Array of record data (id, domain_id, name, type, content, ttl, prio, disabled)

array|null findAllRecordsByContent(string $content, string|null $type = null)

findRecordsByContent(), or null when the backend could not see every match.

Parameters

string $content

Record content, exact match

string|null $type

Optional record type filter

Return Value

array|null

Array of record data, or null when the lookup may be incomplete

string getSOARecord(int $domainId)

Get SOA record content for a zone.

Parameters

int $domainId

Domain ID

Return Value

string

SOA content or empty string

array getZoneRecords(int $domainId, string $zoneName)

Get all records for a zone from the DNS backend.

Returns a flat array of record data. In SQL mode, records include numeric IDs. In API mode, IDs are resolved from the database. ENT records (null/empty type) are excluded.

Parameters

int $domainId

Domain ID

string $zoneName

Zone name (needed for API calls)

Return Value

array

Array of record data arrays

bool hasSoaEditApi(int $domainId)

Check whether the zone has soa_edit_api configured in PowerDNS.

Returns false for SQL backends (not applicable).

Parameters

int $domainId

Return Value

bool

bool setZoneSerialPolicy(int $domainId, string $zoneName, array $properties)

Set the zone's SOA serial policy metadata.

Keys are the zone-object property names from MetadataDefinitions::SERIAL_POLICY_PROPERTY_KINDS. An empty string clears the policy. API backend updates the zone object; SQL backend replaces the matching domainmetadata rows.

Parameters

int $domainId
string $zoneName
array $properties

Return Value

bool

bool addSupermaster(string $masterIp, string $nsName, string $account)

Add a supermaster (autoprimary).

Parameters

string $masterIp

Supermaster IP address

string $nsName

Nameserver hostname

string $account

Account name

Return Value

bool

bool deleteSupermaster(string $masterIp, string $nsName)

Delete a supermaster (autoprimary).

Parameters

string $masterIp

Supermaster IP address

string $nsName

Nameserver hostname

Return Value

bool

array getSupermasters()

Get all supermasters.

Return Value

array

Array of supermaster records

bool updateSupermaster(string $oldMasterIp, string $oldNsName, string $newMasterIp, string $newNsName, string $account)

Update a supermaster.

Parameters

string $oldMasterIp

Original IP

string $oldNsName

Original nameserver

string $newMasterIp

New IP

string $newNsName

New nameserver

string $account

Account name

Return Value

bool

array getCatalogMembers(string $catalogName)

Zones carrying the given catalog.

PowerDNS only publishes a member whose kind is MASTER or PRODUCER and which has an enabled apex SOA, so the kind is returned for callers to flag the rest.

Parameters

string $catalogName

Producer zone name, lowercase and without a trailing dot

Return Value

array

array getZonesByKind(string $kind)

Zones of one kind, with the catalog each currently belongs to.

Parameters

string $kind

A ZoneType constant

Return Value

array

string getZoneCatalog(int $domainId)

Catalog the zone belongs to, lowercase and without a trailing dot, or '' when it is not a member.

Parameters

int $domainId

Domain ID

Return Value

string

bool updateZoneCatalog(int $domainId, string $catalogName)

Join $catalogName, or leave the current catalog when it is ''.

Parameters

int $domainId

Domain ID

string $catalogName

Producer zone name in canonical form, or '' to clear

Return Value

bool

array searchDnsData(string $query, string $objectType = 'all', int $max = 100)

Search for zones and records matching a query.

Returns separate arrays for zone matches and record matches. Results contain only DNS data - callers must enrich with Poweradmin metadata (ownership, permissions).

Parameters

string $query

Search query (supports wildcards)

string $objectType

Filter: 'all', 'zone', 'record', or 'comment' (API backend only)

int $max

Maximum results

Return Value

array

comments lists RRset comment hits (API backend)

bool isApiBackend()

Check if this is the API backend.

Callers can use this to adjust behavior (e.g., skip manual SOA serial updates, show notices about search limitations).

Return Value

bool

bool supportsLocalWriteTransaction()

Whether backend writes can be wrapped in a transaction on the Poweradmin database.

True for the SQL backend, where the PowerDNS tables share the connection. False for the API backend: it writes over HTTP and then reads the local zones table for the new ids, and an open transaction would hide those rows.

Return Value

bool

bool recordIdsAreNumeric()

Whether record ids are the integer records.id values.

True for the SQL backend. False for the API backend, whose record ids are encoded composite keys (see RecordIdentifier) that do not fit an INT column.

Return Value

bool

bool managesSoaRecord()

Whether the backend writes and maintains the apex SOA of the zones it creates.

True for the API backend, where PowerDNS seeds the SOA on zone creation and template SOA records are skipped. False for the SQL backend, which stores whatever SOA Poweradmin writes.

Return Value

bool

bool allocatesZoneIdsLocally()

Whether zone ids are allocated from the local zones table rather than the PowerDNS domains table.

True for the API backend: createZone() inserts the zones row itself and a zone is identified by that row alone. False for the SQL backend, where the id is domains.id, the caller adds the zones row and a zone without a domains row is stale.

Return Value

bool

bool providesSignedSerial()

Whether the zone list can carry the serial PowerDNS serves for signed zones.

True for the API backend, whose zone list reports the signed serial. False for the SQL backend, which only sees the stored SOA serial.

Return Value

bool

bool supportsRecordCountSort()

Whether zone lists can be ordered by record count across every page.

True for the SQL backend, which counts in the query. False for the API backend, where counts are resolved per page and a sort would only order the rows already on screen.

Return Value

bool

bool supportsGroupSort()

Whether zone lists can be ordered by owning group.

True for the SQL backend, which joins the Poweradmin ownership tables in the list query. False for the API backend, whose zone list comes from PowerDNS and cannot join them.

Return Value

bool

bool supportsZoneRetrieve()

Whether a secondary zone can be pulled from its primary on request.

True for the API backend, and for the SQL backend when a PowerDNS API is configured. False otherwise, as there is no way to trigger a transfer.

Return Value

bool

bool supportsZoneNotify()

Whether a primary zone can be told to send NOTIFY on request.

True for the API backend, and for the SQL backend when a PowerDNS API is configured. False otherwise, as there is no way to trigger a NOTIFY.

Return Value

bool

bool syncsZoneListFromServer()

Whether the local zone list is a mirror that can be refreshed from the server.

True for the API backend, where the zones table is synced from PowerDNS. False for the SQL backend, where the domains table is the source itself.

Return Value

bool