PHP library for modifying an PowerDNS MySQL database
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


PHP library for modifying an PowerDNS MySQL database


//setup the database config
$db = array(
	 'host'		=>	'localhost'
	,'user'		=>	'pdns'
	,'password'	=>	''
	,'driver'	=>	'mysql'
	,'port'		=>	3306
Config::set('pdns.db',$db); unset($db);

$domain = PDNS::fetchDomain('');
$domain = PDNS::fetchDomainByHost('');
$record = PDNS::fetchRecord(array('id'=>1));

//update - updates or creates record and finds it by ident
//this is the main function unless advanced actions are needed
$rv = PDNS::update('','','A');
if($rv === false)
	throw new Exception('Failed to update record:');

//delete a record the preferred way
$rv = PDNS::delete('','','A');

//raw create record
$id = PDNS::createRecord(array(
	 'domain_id'		=>	1
	,'name'				=>	''
	,'type'				=>	'A'
	,'content'			=>	''
	,'ttl'				=>	60
	,'prio'				=>	''

//update raw record
$rv = PDNS::updateRecord(1,array('type'=>'CNAME','content'=>''));

//delete raw record
$rv = PDNS::deleteRecord(array('id'=>1));


(array) PDNS::fetchDomain($name)

Get a domain by its name and return the database row

(array) PDNS::fetchDomainByHost($name)

Take a FQDN and return its given domain database row

(mixed) PDNS::update($identifier,$data,$type='A')

  • $identifier Ident that gets passed to PDNS::fetchDomainByHost()
  • $data The record data eg:
  • $type The record type defaults to A Returns the record ID on creation, TRUE on update, FALSE on failure

(mixed) PDNS::delete($identifier,$data,$type='A')

  • $identifier The host identifier eg:
  • $data The record data eg:
  • $type Record type which defaults to A Returns FALSE on failure, TRUE on success

Internal Refernce

This is for raw database actions, generally more advanced usage.

(mixed) PDNS::createRecord($args)

Takes any amount of arguments to create a database record. The current record schema looks like this

  • id Record ID number
  • domain_id Domain ID number
  • name The record name eg:
  • type Record type eg: A
  • content Record content eg:
  • ttl Record TTL eg: 60
  • prio The record priority mainly used for MX records eg: 10
  • change_date This gets set automatically

(mixed) PDNS::fetchRecord($args)

Similar to create by takes an array of arguments related to the schema and returns the database row. Returns FALSE on failure

(bool) PDNS::updateRecord($id=null,$args=array())

  • $id Record ID number
  • $args Parameters to update, see the schema for PDNS::createRecord() Returns TRUE on success, FALSE on failure

(bool) PDNS::deleteRcord($args=array())

  • $args Similar to PDNS::fetchRecord() Returns TRUE on success, FALSE on failure