I'm using following configuration in application.ini for database

resources.db.adapter = "Mysqli"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "root"
resources.db.params.dbname = "dbname"
resources.db.params.charset = "utf8"

Next using standard Model/Mapper/DbTable classes to gain access to database like this

Now I wish to access another database however with same table structure as local database. How do i switch my database for your specific controller/action where I wish to show data for other database.

Thanks.

You should use Zend_Application_Resource_Multidb

There's a good example of its usage here, underneath the heading Different user/host.

Similar question(s) on Stackoverflow

  1. Can't connect to external database with Zend Framework but mysql connect works.

EDIT: I additionally learned that even if I'd the next lines during my Model inherited from Zend_Db_Table_Abstract it wasn't hooking up towards the remote DB.

protected $_schema  = 'chdpformglobal';
protected $_adapter = 'db_remote'; 

And So I checked this function in Zend_Db_Table_Abstract

protected function _setupDatabaseAdapter()
    {
        if (! $this->_db) {
            $this->_db = self::getDefaultAdapter();
            if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
                require_once 'Zend/Db/Table/Exception.php';
                throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this));
            }
        }
    }

If it is exactly the same for you personally, add the next lines for your constructor:

public function __construct() {
    $front = Zend_Controller_Front::getInstance();
    $bootstrap = $front->getParam('bootstrap');
    $resource = $bootstrap->getPluginResource('multidb');
    $this->_db = $resource->getDb('chdpg');
}