Hi, 2009/10/3 W Itch <[email protected]> > My edit view page breaks and says Error in the browser when I try to store > the $database object into registry. > Going from Zend Framework in Action 1.7.1 code to 1.8 and above is > confusing to me :-( > > My question is basically this: In ZF 1.7.1 you store the database into > registry like this. But how is this accomplished in ZF 1.8 and above? > > > 1. protected function _initRegDatabase() > 2. { > 3. $db = Zend_Db::factory($config->db); > 4. Zend_Db_Table_Abstract::setDefaultAdapter($db); > 5. Zend_Registry::set('db', $db); > 6. } > > The error is about $config as it doesn't exist in the _initRegDatabase() method. I would suggest adding a "protected $_config" variable to your Bootstrap class then in your _initRegConfig() method, change it to:
"$this->_config = new Zend_Config..." Then in your _initRegdatabase() function you can use: "$db = Zend_Db::factory($this->_config->db);" That should solve the problem. Alan.
