if ($p = $this->p('db.host')) $this->host = $p;
# Add args to pdo
- foreach (array(
+ foreach ([
'host' => 'host',
'port' => 'port',
'user' => 'user',
'password' => 'password',
'name' => 'dbname',
'charset' => 'charset',
- ) as $k => $v) {
+ ] as $k => $v) {
#self::debug($k);
if ($v=='charset' and $this->type=='pgsql') continue;
if (empty($this->$k)) continue;
$this->pdo = preg_replace("/\b$v=[^;]*(;|$)/","",$this->pdo);
$this->pdo .= (preg_match('/[:;]$/',$this->pdo) ? '' : ';') . "$v=".$this->$k;
}
-#bye($this->pdo);
}
foreach(['name','host','file'] as $p) {
if (!empty($this->$p)) $msg .= " $p=".$this->$p;
}
- $msg .= "\n".$e->getMessage();
- throw new Exception($msg, (int)$e->getCode());
+ $msg .= "\n ".$e->getMessage();
+ #throw new Exception($msg, (int)$e->getCode());
self::bye($msg);
}
#}
if (empty($this->conn)) {
- $this->bye("Can't connect to: ".$this->pdo_info($this->pdo));
+ $this->bye("Connection failed: ".$this->pdo_info($this->pdo));
return false;
}