diff --git a/src/DDLWrapper/Db/Adapter/PostgresAdapter.php b/src/DDLWrapper/Db/Adapter/PostgresAdapter.php index 6881948..1b2e39d 100644 --- a/src/DDLWrapper/Db/Adapter/PostgresAdapter.php +++ b/src/DDLWrapper/Db/Adapter/PostgresAdapter.php @@ -37,6 +37,8 @@ class PostgresAdapter extends PdoAdapter implements AdapterInterface { const INT_SMALL = 65535; + protected $options = Array(); + /** * Columns with comments * @@ -44,39 +46,16 @@ class PostgresAdapter extends PdoAdapter implements AdapterInterface */ protected $columnsWithComments = array(); + private function getOptions(){ + return $this->options; + } + /** * {@inheritdoc} */ public function connect() { - if (null === $this->connection) { - if (!class_exists('PDO') || !in_array('pgsql', \PDO::getAvailableDrivers(), true)) { - // @codeCoverageIgnoreStart - throw new \RuntimeException('You need to enable the PDO_Pgsql extension for Phinx to run properly.'); - // @codeCoverageIgnoreEnd - } - - $db = null; - $options = $this->getOptions(); - - // if port is specified use it, otherwise use the PostgreSQL default - if (isset($options['port'])) { - $dsn = 'pgsql:host=' . $options['host'] . ';port=' . $options['port'] . ';dbname=' . $options['name']; - } else { - $dsn = 'pgsql:host=' . $options['host'] . ';dbname=' . $options['name']; - } - - try { - $db = new \PDO($dsn, $options['user'], $options['pass'], array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)); - } catch (\PDOException $exception) { - throw new \InvalidArgumentException(sprintf( - 'There was a problem connecting to the database: %s', - $exception->getMessage() - )); - } - - $this->setConnection($db); - } + } /**