Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Change port in PostgreSQLDbAdapter

How i can change the default port in PostgreSQLDbAdapter?



9.6k
Accepted
answer
edited May '15

You can declare the port in the services and config

<?php
// config
return new \Phalcon\Config(array(
    'database' => array(
        'adapter'     => 'Postgresql',
        'host'        => 'localhost',
        'port'     => '5432'
        'username'    => 'postgres',
        'password'    => '123456',
        'dbname'      => 'database',

    ),
<?php
// services
$di->set('db', function () use ($config) {
    return new DbAdapter(array(
        'host' => $config->database->host,
        'port' => $config->database->port,
        'username' => $config->database->username,
        'password' => $config->database->password,
        'dbname' => $config->database->dbname,

    ));
});