beberlei / zf-doctrine

A Zend Framework 1.x and Doctrine 1.2 Integration - UNMAINTAINED
101 stars 21 forks source link

Problem with bound components on multiple connections #17

Closed philicious closed 2 years ago

philicious commented 14 years ago

So here is the scenario: You have 2 (or more ) models on different connections but when calling Doctrine::getTable('Default_Model_Something') which is set to the first dsn, it throws an exception because Doctrine_Manager::getInstance()->getConnectionForComponent($componentName) returns the second connections name which results in Doctrine trying to query wrong DB. Both components have same connection name in Doctrine_Manager::$_bound at this moment.

I have traced thru the ZFDoctrine code and ZFDoctrine actually reads both dsn's out correct and correctly binds both components to their respective connection. But somewhere on the way to Doctrine it gets messed up.

I could workaround it by adding Doctrine_Manager::getInstance()->bindComponent('Default_Model_Something', 'default'); to the Bootstrap _initModuleLoaders() at the end of setting the Doctrine Module Autoloader

ghost commented 13 years ago

Meanwhile I encountered an additional problem related to multiple DSNs: If you want to use execute-migration, zf-doctrine doesnt pass any connection to Doctrine_Core::migrate and new Doctrine_Migration(..) which causes Doctrine to pick the wrong DSN, where it cant find the migration_version table. I fixed the ZFDoctrine_Tool_DoctrineProvider class and will fork ZFDoctrine in the next days..