i am using a modular architecture with Zend framework, and i want to use the module specific database configuration such that each module's model employs its own database configuration.
This is my sample application architecture:
- application
- modules
- admin
- controllers
- models
- DbTable
- Users.php
- DbTable
- views
- configs
- module.ini
- admin
- configs
- application.ini
- modules
From the above architecture, i have the module "admin" and i have specified its database configuration in admin/configs/module.ini like:
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "*****"
resources.db.params.password = "*****"
resources.db.params.dbname = "********"
Now I want to use this configuration in the models of "admin" module.
FYI, Iam instantiating the model in the "admin" module's controller like:
$admin = new Admin_Models_DbTable_Users();
$admin_users = $admin->fetchUsers();
And in the "admin" module's model, i am executing the queries like:
public function fetchUsers()
{
$sql = "select * from users";
return $this->getAdapter()->fetchAll($sql, array(), Zend_Db::FETCH_OBJ);
}
How can i load the database configuration in admin/configs/module.ini in my "admin" module's database adapter such that it uses that configuration? Do i need to use Zend Registry or set any options in admin module's bootstrap file ?