aboutsummaryrefslogtreecommitdiffstats
path: root/include/dba/dba_pdo.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-10-20 17:04:43 -0700
committerzotlabs <mike@macgirvin.com>2016-10-20 17:04:43 -0700
commit04ac04e0ada6b8dbe3f512379abd2859eb758173 (patch)
tree2a61195efe29fc47a1f88985b361806fc3e68f0a /include/dba/dba_pdo.php
parent29340152b6a924a27dc62363d623e3dd287b5a2a (diff)
downloadvolse-hubzilla-04ac04e0ada6b8dbe3f512379abd2859eb758173.tar.gz
volse-hubzilla-04ac04e0ada6b8dbe3f512379abd2859eb758173.tar.bz2
volse-hubzilla-04ac04e0ada6b8dbe3f512379abd2859eb758173.zip
allow a dsn override to the database via the server argument. This could be used to allow unix domain sockets and other unusual configurations.
Diffstat (limited to 'include/dba/dba_pdo.php')
-rwxr-xr-xinclude/dba/dba_pdo.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php
index bb89df6be..c2f9c5b09 100755
--- a/include/dba/dba_pdo.php
+++ b/include/dba/dba_pdo.php
@@ -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) {