Example #1
0
 private function __construct()
 {
     if (!defined('PHPWS_DSN')) {
         throw new Exception('Database connection DSN is not set.');
     }
     $dsnArray = \Database::parseDSN(PHPWS_DSN);
     $dsn = $this->createDsn($dsnArray['dbtype'], $dsnArray['dbhost'], $dsnArray['dbname']);
     $this->pdo = new \PDO($dsn, $dsnArray['dbuser'], $dsnArray['dbpass'], array(\PDO::ATTR_PERSISTENT => true));
     // Make sure PDO will throw exceptions on error
     $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
 }