public function __construct($database, $host, $username, $password, $persistent = false) { $this->database = $database; $ncDnsResolver = new ncDnsResolver(); $host = $ncDnsResolver->resolveDNS($host, false); $this->host = trim($host, ";"); $this->username = $username; $this->password = $password; $this->persistent = $persistent; }
protected function connect() { try { $ncDnsResolver = new ncDnsResolver(); $this->dsn = $ncDnsResolver->resolveDNS($this->dsn); $this->connection = new PDO($this->dsn, $this->username, $this->password); if ($this->reconnect) { $this->connection = new ncPdoPersistent($this->connection, $this->dsn, $this->username, $this->password); } if ($this->debug) { $this->connection = new ncPdoDebug($this->connection); } } catch (PDOException $e) { throw new ncDatabaseException($e->getMessage() . '[dsn: ' . $this->dsn . ']'); } $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }