Zend Framework

Exception thrown when Zend_Application_Resource_Multidb used with pdo_pgsql adapter

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.10.0
  • Fix Version/s: 1.10.5
  • Labels:
    None

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/zend.application.available-resources.html#zend.application.available-resources.multidb

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); }

  1. Multidb.patch
    16/Feb/10 5:44 PM
    1 kB
    Ramon Henrique Ornelas
  2. Multidb2.patch
    19/Feb/10 1:11 PM
    2 kB
    Ramon Henrique Ornelas

Activity

Hide
Dolf Schimmel (Freeaqingme) added a comment -

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

Show
Dolf Schimmel (Freeaqingme) added a comment - Thank you for reporting this issue. Will evaluate if this should be solved in Zend_Db or in Zend_App.
Hide
Ralph Schindler added a comment -

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.

Show
Ralph Schindler added a comment - 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.
Hide
Dolf Schimmel (Freeaqingme) added a comment -

Resolved with r21013. Thank you for reporting the issue.

Show
Dolf Schimmel (Freeaqingme) added a comment - Resolved with r21013. Thank you for reporting the issue.
Hide
Ramon Henrique Ornelas added a comment -

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'

Show
Ramon Henrique Ornelas added a comment - 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'
Hide
Ramon Henrique Ornelas added a comment -

Attached patch

Show
Ramon Henrique Ornelas added a comment - Attached patch
Hide
Ramon Henrique Ornelas added a comment -

Ignore the first patch no contains test unit.

See the patch Multidb2.patch.

Show
Ramon Henrique Ornelas added a comment - Ignore the first patch no contains test unit. See the patch Multidb2.patch.

People

Vote (2)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: