Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Cannot connect via Doctrine/PostgreSQL/unix_socket #1788

Closed
aparod opened this Issue · 2 comments

3 participants

@aparod

This is an issue with Symfony 2.0 RC6. Please refer to vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php at the _constructPdoDsn method.

In order to connect via unix socket, the "host=" parameter of the dsn must be absent. For example:

(works) pgsql: dbname=dbname user=user password=password

If "host=" is present, even if it is empty, it will not connect via socket.

(does not work) pgsql: host= dbname=dbname user=user password=password

Symfony provides a default host setting ("localhost"). In order to remove this default, I have to set my host to an empty string. This empty string is then being sent along to the PDO driver, which results in "host=" being added to the dsn. As far as I can tell, there is no way to tell Symfony to completely omit the host parameter.

Proposed solutions:
1. When parsing the configuration, check for an empty host and remove the "host" key before sending the parameters array to the db driver
2. or, modify the _constructPdoDsn method to only include "host" if it is not empty:

        if (isset($params['host']) && $params['host'] != '') {
            $dsn .= 'host=' . $params['host'] . ' ';
        }

I verified I can connect properly after implementing the 2nd solution. I leave it to you to decide which solution is more correct.

@fabpot
Owner

I also tend to prefer the second solution as it makes Doctrine more robust. @beberlei: What do you think?

@beberlei beberlei closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.