mirror of
https://github.com/silverstripe/silverstripe-postgresql
synced 2024-10-22 17:05:45 +02:00
BUG Fix installer for 4.0 (#58)
This commit is contained in:
parent
d8aab6383e
commit
a5738dbfd1
@ -1,13 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
|
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
|
||||||
|
use SilverStripe\PostgreSQL\PostgreSQLDatabaseConfigurationHelper;
|
||||||
|
|
||||||
// PDO Postgre database
|
// PDO Postgre database
|
||||||
DatabaseAdapterRegistry::register(array(
|
DatabaseAdapterRegistry::register(array(
|
||||||
/** @skipUpgrade */
|
/** @skipUpgrade */
|
||||||
'class' => 'PostgrePDODatabase',
|
'class' => 'PostgrePDODatabase',
|
||||||
|
'module' => 'postgresql',
|
||||||
'title' => 'PostgreSQL 8.3+ (using PDO)',
|
'title' => 'PostgreSQL 8.3+ (using PDO)',
|
||||||
'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php',
|
'helperPath' => __DIR__.'/code/PostgreSQLDatabaseConfigurationHelper.php',
|
||||||
|
'helperClass' => PostgreSQLDatabaseConfigurationHelper::class,
|
||||||
'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())),
|
'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())),
|
||||||
'missingExtensionText' =>
|
'missingExtensionText' =>
|
||||||
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
|
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
|
||||||
@ -20,8 +23,10 @@ DatabaseAdapterRegistry::register(array(
|
|||||||
DatabaseAdapterRegistry::register(array(
|
DatabaseAdapterRegistry::register(array(
|
||||||
/** @skipUpgrade */
|
/** @skipUpgrade */
|
||||||
'class' => 'PostgreSQLDatabase',
|
'class' => 'PostgreSQLDatabase',
|
||||||
|
'module' => 'postgresql',
|
||||||
'title' => 'PostgreSQL 8.3+ (using pg_connect)',
|
'title' => 'PostgreSQL 8.3+ (using pg_connect)',
|
||||||
'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php',
|
'helperPath' => __DIR__.'/code/PostgreSQLDatabaseConfigurationHelper.php',
|
||||||
|
'helperClass' => PostgreSQLDatabaseConfigurationHelper::class,
|
||||||
'supported' => function_exists('pg_connect'),
|
'supported' => function_exists('pg_connect'),
|
||||||
'missingExtensionText' =>
|
'missingExtensionText' =>
|
||||||
'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not
|
'The <a href="http://php.net/pgsql">pgsql</a> PHP extension is not
|
||||||
|
@ -20,6 +20,7 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
|
|||||||
/**
|
/**
|
||||||
* Create a connection of the appropriate type
|
* Create a connection of the appropriate type
|
||||||
*
|
*
|
||||||
|
* @skipUpgrade
|
||||||
* @param array $databaseConfig
|
* @param array $databaseConfig
|
||||||
* @param string $error Error message passed by value
|
* @param string $error Error message passed by value
|
||||||
* @return mixed|null Either the connection object, or null if error
|
* @return mixed|null Either the connection object, or null if error
|
||||||
@ -31,7 +32,6 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
|
|||||||
$password = empty($databaseConfig['password']) ? '' : $databaseConfig['password'];
|
$password = empty($databaseConfig['password']) ? '' : $databaseConfig['password'];
|
||||||
$server = $databaseConfig['server'];
|
$server = $databaseConfig['server'];
|
||||||
|
|
||||||
/** @skipUpgrade */
|
|
||||||
try {
|
try {
|
||||||
switch ($databaseConfig['type']) {
|
switch ($databaseConfig['type']) {
|
||||||
case 'PostgreSQLDatabase':
|
case 'PostgreSQLDatabase':
|
||||||
@ -45,7 +45,7 @@ class PostgreSQLDatabaseConfigurationHelper implements DatabaseConfigurationHelp
|
|||||||
$conn = @new PDO('postgresql:host='.$server.';dbname=postgres;port=5432', $username, $password);
|
$conn = @new PDO('postgresql:host='.$server.';dbname=postgres;port=5432', $username, $password);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$error = 'Invalid connection type';
|
$error = 'Invalid connection type: ' . $databaseConfig['type'];
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user