/**
* Connect with PDO
*
* @return null
*/
private function connect()
{
// Connecting with PDO
try {
switch ($this->dbType) {
case 'sqlite':
$this->dbHandler = @new PDO("sqlite:" . $this->dbName, null, null, $this->pdoSettings);
break;
case 'mysql':
case 'pgsql':
case 'dblib':
$this->dbHandler = @new PDO($this->dsn, $this->user, $this->pass, $this->pdoSettings);
// Execute init commands once connected
foreach ($this->dumpSettings['init_commands'] as $stmt) {
$this->dbHandler->exec($stmt);
}
// Store server version
$this->version = $this->dbHandler->getAttribute(PDO::ATTR_SERVER_VERSION);
break;
default:
throw new Exception("Unsupported database type (" . $this->dbType . ")");
}
} catch (PDOException $e) {
throw new Exception("Connection to " . $this->dbType . " failed with message: " . $e->getMessage());
}
$this->dbHandler->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_NATURAL);
$this->typeAdapter = TypeAdapterFactory::create($this->dbType, $this->dbHandler);
}