SqlDnsBackendProvider
class SqlDnsBackendProvider implements DnsBackendProvider (View source)
SQL-based DNS backend provider.
Performs DNS data operations directly against the PowerDNS database tables. This is the default backend and preserves the existing behavior.
Methods
No description
Create a new zone in the DNS backend.
Delete a zone and all its associated DNS data (records, metadata, cryptokeys).
Change zone type (NATIVE, MASTER, SLAVE, PRODUCER, CONSUMER).
Update slave zone's master IP address.
Request an immediate AXFR transfer of a secondary (slave) zone from its master.
Update zone account field.
Zones carrying the given catalog.
Zones of one kind, with the catalog each currently belongs to.
Catalog the zone belongs to, lowercase and without a trailing dot, or '' when it is not a member.
Join $catalogName, or leave the current catalog when it is ''.
Add a DNS record.
Add a DNS record and return its ID.
Create a DNS record atomically with optional disabled flag.
Edit an existing DNS record.
Delete a DNS record by ID.
Delete all records for a given domain.
Check if a zone exists by name.
Get zone info by ID.
Get zone name by domain ID.
Get zone ID by name.
Get zone type by domain ID.
Get zone master by domain ID.
Get a single record by ID.
Get zone ID from a record ID.
Get bulk zone stats (DNSSEC state, SOA serials) keyed by zone name.
Count non-ENT records in a zone.
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.
Check if a record with given attributes exists.
Get records by zone ID, optionally filtered by type.
Get the records at one name in a zone, optionally filtered by type.
Get SOA record content for a zone.
Find the best matching reverse zone ID for a PTR record name.
Get all zones from the DNS backend.
Get a single zone by name with its type, master, and DNSSEC status.
Get all records for a zone from the DNS backend.
Search for zones and records matching a query.
Update the SOA serial for a zone.
Add a supermaster (autoprimary).
Delete a supermaster (autoprimary).
Get all supermasters.
Update a supermaster.
Check if this is the API backend.
Check whether the zone has soa_edit_api configured in PowerDNS.
Set the zone's SOA serial policy metadata.
Details
__construct(PDO $db, ConfigurationInterface $config, LoggerInterface|null $logger = null)
No description
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).
Does NOT delete Poweradmin-internal data (zones table, records_zone_templ, etc.)
- those are handled by the caller.
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.
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.
Only the API backend can trigger this. The SQL backend returns false, since PowerDNS pulls secondaries on its own refresh schedule there.
bool
updateZoneAccount(int $domainId, string $account)
Update zone account field.
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.
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 ''.
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)
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)
Create a DNS record atomically with optional disabled flag.
In SQL mode, wraps the INSERT in a transaction with deadlock retry. In API mode, delegates to addRecordGetId + optional editRecord.
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
deleteRecordsByDomainId(int $domainId)
Delete all records for a given domain.
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.
array|null
getRecordById(int|string $recordId)
Get a single record by ID.
int
getZoneIdFromRecordId(int|string $recordId)
Get zone ID from a record ID.
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.
int
countZoneRecords(int $domainId)
Count non-ENT records in a zone.
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.
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.
Names match case-insensitively, per RFC 4343.
string
getSOARecord(int $domainId)
Get SOA record content for a zone.
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.
Returns raw zone data without Poweradmin metadata (ownership, comments). Each zone array contains: name, type, dnssec (bool), master (string).
array|null
getZoneByName(string $zoneName)
Get a single zone by name with its type, master, and DNSSEC status.
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.
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).
bool
updateSOASerial(int $domainId)
Update the SOA serial for a zone.
In API mode this is a no-op since PowerDNS handles serial increments automatically via soa_edit_api.
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.
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).
bool
hasSoaEditApi(int $domainId)
Check whether the zone has soa_edit_api configured in PowerDNS.
Returns false for SQL backends (not applicable).
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.