ZF-3436: dsn problem on Zend_Db_Adapter_Pdo_Oci

Issue Type: Bug Created: 2008-06-11T01:31:12.000+0000 Last Updated: 2009-02-18T13:59:24.000+0000 Status: Resolved Fix version(s): - 1.7.6 (02/Mar/09)

Reporter: markus (proover) Assignee: Jurrien Stutterheim (norm2782) Tags: - Zend_Db

Related issues: Attachments:



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

I used the following params:

<pre class="highlight">
username   = userName
password   = password
dbname     = dev

Zend_Db_Adapter_Pdo_Oci generates the following dsn:

<pre class="highlight">

this fails on the oracle side with the error:

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


Posted by Marcel Blok (mblok) on 2008-06-18T07:15:13.000+0000

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.

Posted by Marcel Blok (mblok) on 2008-06-18T07:22:31.000+0000

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;

Posted by Jurrien Stutterheim (norm2782) on 2009-02-18T00:10:11.000+0000

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

Posted by Jurrien Stutterheim (norm2782) on 2009-02-18T13:59:21.000+0000

Resolved in r. 14107

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.