We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Change port in PostgreSQLDbAdapter

How i can change the default port in PostgreSQLDbAdapter?



17.7k
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,

    ));
});