I am trying to register my default database adapter in my bootstrap.php file so that I can access it where ever I am. This is my code so far:
//bootstrap.php
protected function _initDb()
{
$dbAdapter = Zend_Db::factory(Zend_Registry::get('configuration')
->resources->db->adapter,
Zend_Registry::get('configuration')
->resources->db->params->toArray());
Zend_Registry::set('dbAdapter', $dbAdapter);
Zend_Db_Table_Abstract::setDefaultAdapter($dbAdapter);
}
I am then trying to call it in one of my models by saying:
//exampleModel.php
$select = $this->_getDbAdapter()
->select()
->from(array('t' => $this->_getTable()->getName()),
array('name'))....
However I am just getting the error:
Call to undefined method Application_Model_Example::_getdbAdapter() in...
So obviously it is looking for it within my current class and can't find it...