Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4340386
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:20:31+00:00 2026-05-21T11:20:31+00:00

i am using a modular architecture with Zend framework, and i want to use

  • 0

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
        • views
        • configs
          • module.ini
    • configs
      • application.ini

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:20:32+00:00Added an answer on May 21, 2026 at 11:20 am

    i am following a different approach, as suggested by one of my friends:

    In the module’s bootstrap file, i am setting the module’s db adapter into the Registry, and in the module’s model file, i am getting the module’s db adapter from the registry using a custom method: getAdapter()

    Code in ….application/modules/admin/Bootstrap.php

    protected function _initAutoload()
        {       
            $configuration = new Zend_Config_Ini(
                    APPLICATION_PATH . '/modules/admin/configs/module.ini', 
                    'production'
                    );
    
            $params = $configuration->resources->db->params->toArray();
            $DB = new Zend_Db_Adapter_Pdo_Mysql($params);
    
            Zend_Registry::set('DB',$DB);       
    
        }
    

    Code in …application/modules/admin/DbTable/Users.php

    public function getAdapter()
        {   
            $registry   = Zend_Registry::getInstance();     
            return $registry['DB']; 
        }
    

    So now the $this->getAdapter() in admin module’s fetchUsers() method will have the db adapter of “admin” module. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been using a modular structure for my zend framework application. This is
How to develop modular application using Zend framework?
I'm using the zend modular director structure, i.e. application modules users controllers . .
To use modular exponentiation as you would require when using the Fermat Primality Test
We have the beginnings of a modular wpf application built using prism. We want
I am structuring a modular php application using MySQL as my database. I would
I am building a modular framework for a PHP MVC site. I am using
I'm trying to set up a modular Zend Framework project with frontend and backend
What is the best way, using PHP, to design a modular system that can
I have a simple Sinatra app that is configured using the modular style. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.