PHP code example of openlss / lib-pdns

1. Go to this page and download the library: Download openlss/lib-pdns library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

openlss / lib-pdns example snippets



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

//getters
$domain = PDNS::fetchDomain('test.com');
$domain = PDNS::fetchDomainByHost('www.test.com');
$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('www.test.com','1.2.4.5','A');
if($rv === false)
	throw new Exception('Failed to update record: www.test.com');

//delete a record the preferred way
$rv = PDNS::delete('www.test.com','1.2.3.4','A');

//raw create record
$id = PDNS::createRecord(array(
	 'domain_id'		=>	1
	,'name'				=>	'ww1.test.com'
	,'type'				=>	'A'
	,'content'			=>	'1.2.3.4'
	,'ttl'				=>	60
	,'prio'				=>	''
));


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

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