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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user