ZF-3436: dsn problem on Zend_Db_Adapter_Pdo_Oci



I want to connect to a in tnsnames.ora defined database but it fails because of the generated dns.

I used the following params:

username   = userName
password   = password
dbname     = dev

Zend_Db_Adapter_Pdo_Oci generates the following dsn:

this fails on the oracle side with the error:

but it should afaik generate the following dsn: ```…


We are experiencing the same problem. The problem is that we want to use our TNSNAMES.ORA file for the connections. If the connection string is build up in the current way, it is like an entry of the TNSNAMES.ORA file, and so the file will not be used. The problem then is that the host is not given, and the illegal ADDRESS parameters exception is thrown.

To resolve this I see two options: either create the shorthand version (oci:dbname=xxxxxx) when no host is given, or create a new parameter that can be set to let the code use the short version. The first solution would be most elegant, but it have to be checked if it doesn't break any existing code. It seems to me that the error is triggered because the complete address is missing, so it could never work in this way. But please correct me if I'm wrong.

My proposed solution would be to change the current _dsn() method by the following:

/** * Creates a PDO DSN for the adapter from $this->_config settings. * * @return string */ protected function _dsn() { // baseline of DSN parts $dsn = $this->_config;

    if (isset($dsn['host'])) {
        $tns .= 'dbname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=' . $dsn['host'] . ')';
        if (isset($dsn['port'])) {
            $tns .= '(PORT=' . $dsn['port'] . ')';
        } else {
            $tns .= '(PORT=1521)';
        $tns .= '))(CONNECT_DATA=(SID=' . $dsn['dbname'] . ')))';
    } else {
        $tns = 'dbname=' . $dsn['dbname'];

    if (isset($dsn['charset']))
        $tns .= ';charset=' . $dsn['charset'];

    return $this->_pdoType . ':' . $tns;

That looks like a nice BC way of solving this issue... Ralph: mind if I steal this issue from you? ; )

Resolved in r. 14107