/** * Return the ID of the module in the module table. * * @param string $module Name of the module. * * @return integer The module ID. */ private function _getModuleId($module) { $moduleId = $this->_moduleRow($module, 'id'); if ($moduleId == 0) { $moduleId = $this->_db->lastInsertId($module, 'id'); } return $moduleId; }
public function createZone($domain) { if ($this->getDomainId($domain) === false) { // Zone doesn't exist yet // Create entry in the 'domains' table $this->_db->insert('domains', array('name' => $domain, 'type' => 'MASTER')); $domainId = $this->_db->lastInsertId(); // Create entry in the 'zones' table using the just created domain id $this->_db->insert('zones', array('domain_id' => $domainId, 'owner' => 2, 'comment' => 'Created by MiniThor-core')); $this->addRecord($domainId, $domain, 'SOA', 'ns3.remorse.nl hostmaster.' . $domain . ' 0'); $this->addRecord($domainId, $domain, 'NS', 'ns3.remorse.nl'); $this->addRecord($domainId, $domain, 'NS', 'ns4.remorse.nl'); $this->addRecord($domainId, $domain, 'A', '83.96.134.196'); $this->addRecord($domainId, 'www.' . $domain, 'A', '83.96.134.196'); $this->addRecord($domainId, 'localhost.' . $domain, 'A', '127.0.0.1'); } else { // Zone is already known by PowerDNS throw new Exception(sprintf('Zone for "%s" already exists', $domain)); } }
/** * Saves the current attributes to the DB. */ public function save() { $this->beforeSave(); // Trims out non-fields and serializes data for DB entry. $info = $this->info(true, true); if (!$this->exists) { $this->beforeCreate(); $this->_zendDb->insert($this->tableName(), $info); if (!$this->id) { $this->id = $this->_zendDb->lastInsertId(); } $this->_afterCommand('insert'); $this->exists = true; $this->afterCreate(); } else { $this->_zendDb->update($this->tableName(), $info, 'id = ' . $this->_zendDb->quote($this->id)); $this->_afterCommand('update'); } $this->afterSave(); $this->_lastSaveRow = $this->info(); }