Issues

ZF-9131: Exception thrown when Zend_Application_Resource_Multidb used with pdo_pgsql adapter

Description

When configuring Zend_Application_Resource_Multidb to use a pdo_pgsql adapter as per example in the Programmer's Reference Guide, Zend_Db_Adapter_Pdo_Abstract throws an Zend_Db_Adapter_Exception with the message: SQLSTATE[08006] [7] invalid connection option "adapter"

I based my code on this example: http://framework.zend.com/manual/en/…

The following configuration lines were used:

resources.multidb.db1.adapter = "pdo_pgsql" resources.multidb.db1.host = "localhost" resources.multidb.db1.port = 8000 resources.multidb.db1.username = "myUsername" resources.multidb.db1.password = "myPassword" resources.multidb.db1.dbname = "myDb"

This problem could be solved if the configuration of Zend_Application_Resource_Multidb would be more similar to Zend_Application_Resource_Db and connection parameters are stored in an array called params. E.g.:

resources.multidb.db1.adapter = "pdo_pgsql" resources.multidb.db1.params.host = "localhost" resources.multidb.db1.params.port = 8000 resources.multidb.db1.params.username = "myUsername" resources.multidb.db1.params.password = "myPassword" resources.multidb.db1.params.dbname = "myDb"

To maintain backwards compatibility, the following change could be made to Zend_Application_Resource_Multidb and replace line 81:

$this->_dbs[$id] = Zend_Db::factory($params['adapter'], $params);

with the following:

if (isset($params['params'])) { $this->_dbs[$id] = Zend_Db::factory($params['adapter'], $params['params']); } else { $this->_dbs[$id] = Zend_Db::factory($params['adapter'], $params); }

Comments

Thank you for reporting this issue. Will evaluate if this should be solved in Zend_Db or in Zend_App.

This should be solved in Zend_Application_Resource_Multidb. In fact, the adapter should have been built to accept config objects in the same format as the db adapter with a params key, as noted above. That should be the fix.

Resolved with r21013. Thank you for reporting the issue.

Problem with the option


resources.multidb.db1.isDefaultTableAdapter = 1

Exception: Zend_Db_Adapter_Exception: SQLSTATE[08006] [7] invalid connection option "isDefaultTableAdapter"

Dsn connection Pdo: 'pgsql:host=localhost;dbname=zf_test;isDefaultTableAdapter=1'

Attached patch

Ignore the first patch no contains test unit.

See the patch Multidb2.patch.