This is what I'm using for a multi-database setup.
If you're using Zend_Db_Table, this works nicely with setting the db params in the application.ini file while allowing you to specify a different db connection your dttable files. Of course make adjustments for the class naming and your paths. Terre Abstract code is from http://jaybill.com/2007/09/12/using-the-zend-framework-with-multiple-databas es/ abstract class Core_DB_Table_Abstract extends Zend_Db_Table_Abstract { function Core_DB_Table_Abstract($config = null) { if (isset ( $this->_use_adapter )) { $dbAdapters = Zend_Registry::get ( 'dbAdapters' ); $config = ($dbAdapters [$this->_use_adapter]); } return parent::__construct ( $config ); } } Then extend your dbtable class Core_DB_Models_UserLog extends Core_DB_Table_Abstract { /** * The default table name */ protected $_name = 'cms_userslog'; protected $_use_adapter = 'eedition'; // if not specified will use the isDefaultTableAdapter } In the application.ini create the db references like so. resources.db.tbncms.adapter = mysqli resources.db.tbncms.params.host = localhost resources.db.tbncms.params.username = dbuser resources.db.tbncms.params.password = password resources.db.tbncms.params.dbname = db1 resources.db.tbncms.isDefaultTableAdapter = true resources.db.eedition.adapter = mysqli resources.db.eedition.params.host = localhost resources.db.eedition.params.username = dbuser resources.db.eedition.params.password = password resources.db.eedition.params.dbname = db2 From: Sergio Rinaudo [mailto:[email protected]] Sent: Friday, September 17, 2010 1:27 PM To: [email protected]; [email protected] Subject: FW: [fw-general] Can you have multiple databases? Did you read this page of the documentation? http://zendframework.com/manual/1.10/en/zend.application.available-resources .html#zend.application.available-resources.multidb Sergio Rinaudo > Date: Fri, 17 Sep 2010 11:09:18 -0600 > From: [email protected] > To: [email protected] > CC: [email protected] > Subject: Re: [fw-general] Can you have multiple databases? > > You just need a separate db object for each database > > > > Mark > > On Fri, Sep 17, 2010 at 9:38 AM, tryingtolearn > <[email protected]> wrote: > > > > I can't find anything but "hacks" that others have done. Will zend work with > > multiple databases at the same time? I have data in Oracle, MySQL, and SQL > > Server. I need that info on one page. Thanks. > > -- > > View this message in context: http://zend-framework-community.634137.n4.nabble.com/Can-you-have-multiple-d atabases-tp2544032p2544032.html > > Sent from the Zend Framework mailing list archive at Nabble.com. > > > > > > -- > Have fun or die trying - but try not to actually die.
