Update 'src/DDLWrapper/Db/Adapter/PostgresAdapter.php'
This commit is contained in:
@@ -37,6 +37,8 @@ class PostgresAdapter extends PdoAdapter implements AdapterInterface
|
|||||||
{
|
{
|
||||||
const INT_SMALL = 65535;
|
const INT_SMALL = 65535;
|
||||||
|
|
||||||
|
protected $options = Array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Columns with comments
|
* Columns with comments
|
||||||
*
|
*
|
||||||
@@ -44,39 +46,16 @@ class PostgresAdapter extends PdoAdapter implements AdapterInterface
|
|||||||
*/
|
*/
|
||||||
protected $columnsWithComments = array();
|
protected $columnsWithComments = array();
|
||||||
|
|
||||||
|
private function getOptions(){
|
||||||
|
return $this->options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function connect()
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user