allow a dsn override to the database via the server argument. This could be used to allow unix domain sockets and other unusual configurations.

This commit is contained in:
zotlabs
2016-10-20 17:04:43 -07:00
parent 29340152b6
commit 04ac04e0ad
2 changed files with 21 additions and 15 deletions

View File

@@ -10,14 +10,18 @@ class dba_pdo extends dba_driver {
function connect($server,$scheme,$port,$user,$pass,$db) {
$this->driver_dbtype = $scheme;
$dns = $this->driver_dbtype
. ':host=' . $server . (is_null($port) ? '' : ';port=' . $port)
. ';dbname=' . $db;
// db_logger('dns: ' . $dns);
if(strpbrk($server,':;')) {
$dsn = $server;
}
else {
$dsn = $this->driver_dbtype . ':host=' . $server . (is_null($port) ? '' : ';port=' . $port);
}
$dsn .= ';dbname=' . $db;
try {
$this->db = new PDO($dns,$user,$pass);
$this->db = new PDO($dsn,$user,$pass);
$this->db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e) {