cleaning up code.
This commit is contained in:
@@ -12,24 +12,21 @@ class Postgres extends Connector {
|
||||
{
|
||||
extract($config);
|
||||
|
||||
// Format the initial Postgres PDO connection string. These options are required
|
||||
// for every Postgres connection that is established. The connection strings
|
||||
// have the following convention: "pgsql:host=hostname;dbname=database"
|
||||
$dsn = "pgsql:host={$host};dbname={$database}";
|
||||
|
||||
// Check for any optional Postgres PDO options. These options are not required
|
||||
// to establish a PDO connection; however, may be needed in certain server
|
||||
// or hosting environments used by the developer.
|
||||
foreach (array('port') as $key => $value)
|
||||
// The developer has the freedom of specifying a port for the PostgresSQL
|
||||
// database or the default port (5432) will be used by PDO to create the
|
||||
// connection to the database for the developer.
|
||||
if (isset($config['port']))
|
||||
{
|
||||
if (isset($config[$key]))
|
||||
{
|
||||
$dsn .= ";{$key}={$value}";
|
||||
}
|
||||
$dsn .= ";port={$config['port']}";
|
||||
}
|
||||
|
||||
$connection = new PDO($dsn, $username, $password, $this->options($config));
|
||||
|
||||
// If a character set has been specified, we'll execute a query against
|
||||
// the database to set the correct character set. By default, this is
|
||||
// set to UTF-8 which should be fine for most scenarios.
|
||||
if (isset($config['charset']))
|
||||
{
|
||||
$connection->prepare("SET NAMES '{$config['charset']}'")->execute();
|
||||
|
||||
Reference in New Issue
Block a user