The only thing that is "automatic" regarding the DB is Zend_Db_Table and its default adapter. You can specify the default by using this confing option:
resources.multidb.db2.default = true For everything else, you'll need to inject the db instance into your models (for example, by injecting into a data mapper) or access it statically with: $db = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('multidb')->getDb('db2'); Injection is preferred because it makes unit testing easier. -- Hector On Fri, Mar 19, 2010 at 2:15 AM, Sergio Rinaudo <kaiohken1...@hotmail.com>wrote: > Thank you very much for your advices Hector. > I have one more question, is anything changing on models management using > multidb? > How do a model know which database resource must use? > Thanks > > > Sergio > > > > > ------------------------------ > From: djvir...@gmail.com > Date: Tue, 16 Mar 2010 09:23:26 -0700 > Subject: Re: [fw-general] Using an external database for user credential > To: kaiohken1...@hotmail.com > CC: fw-general@lists.zend.com > > > Take a look at the "multidb" resource: > > > http://framework.zend.com/manual/en/zend.application.available-resources.html > > > <http://framework.zend.com/manual/en/zend.application.available-resources.html>You > could then inject your authentication adapter with the correct db: > > // in controller > $db = > $this->getInvokeArg('bootstrap')->getResource('multidb')->getDb('db2') > $authAdapter = new Zend_Auth_Adapter_DbTable( > $db, > $tabUsers, > 'username', > 'password' > ); > > This would eliminate the need for you to construct your own db adapter from > the config. > > Also, you'll want to use boolean false for isDefaultTableAdapter -- when > it's set to true, that db instance will be used for all Zend_Db_Table > instances by default. > > -- > Hector > > > On Tue, Mar 16, 2010 at 2:34 AM, Sergio Rinaudo > <kaiohken1...@hotmail.com>wrote: > > Hello, > I am in a situation where I have to use an external database to check > credential for user. > Is there any right way to do this in the application ini? > > I thoughts something like > > resources.db2.adapter = // external db adapter > resources.db2.params.host = // external db host > resources.db2.params.username = // external db user > resources.db2.params.password = // external db pass > resources.db2.params.dbname = // external db name > resources.db2.isDefaultTableAdapter = // what am I supposed to put here? > resources.db2.params.charset = UTF8 > resources.db2.profiler.enabled = true > > Save it in the registry whitin bootstrap > > $db2 = // some code > $registry->db2 = $db2; > > Use $db2 to check credential in auth controller > > $db2 = Zend_Registry::get('db2'); > $authAdapter = new Zend_Auth_Adapter_DbTable( > $db2, > $tabUsers, > 'username', > 'password', > "SHA1(CONCAT('".$salt."',?)) AND status_id = '".$status_id."' " > ); > > > Is that a correct way to do or there is something better? > Thanks in advance for all your advices. > > > > Sergio > > > > > ------------------------------ > Lo spazio su Hotmail aumente con le tue esigenze... Vai oltre i > 5GB<http://www.windowslive.it/hotmail/SpazioDisponibile.aspx> > > > > ------------------------------ > Lo spazio su Hotmail aumente con le tue esigenze... Vai oltre i > 5GB<http://www.windowslive.it/hotmail/SpazioDisponibile.aspx> >