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

  • Home
  • SEARCH
  • 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 393143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:13:43+00:00 2026-05-12T16:13:43+00:00

I have here a medium sized intranet site which is written entirely in Zend

  • 0

I have here a medium sized intranet site which is written entirely in Zend FW. The database for the intranet is located on another server. Now I need to extend the intranet with some new functionality. In order to do this I need to connect to another database on the same server (and same DBMS).

The question is now: What is the best way to do this? Should I create a new Zend_Config object and a new Zend_Db_Adapter? Or should I use the existing one and try with the “use otherdbname;” statement to connect within the same session to the new database?

Or is there an even better way to do it?

  • 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-12T16:13:43+00:00Added an answer on May 12, 2026 at 4:13 pm

    One option is to register 2 database handles from within your bootstrap.php, one for each connection. E.g.:

    $parameters = array(
                        'host'     => 'xx.xxx.xxx.xxx',
                        'username' => 'test',
                        'password' => 'test',
                        'dbname'   => 'test'
                       );
    try {
        $db = Zend_Db::factory('Pdo_Mysql', $parameters);
        $db->getConnection();
    } catch (Zend_Db_Adapter_Exception $e) {
        echo $e->getMessage();
        die('Could not connect to database.');
    } catch (Zend_Exception $e) {
        echo $e->getMessage();
        die('Could not connect to database.');
    }
    Zend_Registry::set('db', $db);
    
    $parameters = array(
                        'host'     => 'xx.xxx.xxx.xxx',
                        'username' => 'test',
                        'password' => 'test',
                        'dbname'   => 'test'
                       );
    try {
        $db = Zend_Db::factory('Pdo_Mysql', $parameters);
        $db->getConnection();
    } catch (Zend_Db_Adapter_Exception $e) {
        echo $e->getMessage();
        die('Could not connect to database.');
    } catch (Zend_Exception $e) {
        echo $e->getMessage();
        die('Could not connect to database.');
    }
    Zend_Registry::set('db2', $db);
    

    In your controllers (e.g.):

    public function init()
    {
         $this->db = Zend_Registry::get('db');
         $this->db2 = Zend_Registry::get('db2');
    }
    
    public function fooAction()
    {
        $data = $this->db2->fetchAll('select foo from blah');
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written my first medium-sized project in Scala, and I am now a
I have a series of medium-sized XML documents, which are mainly text with a
Some background: I have what I would consider a medium-sized GWT app deployed to
Sitting here with a simple rails 3 app in which I have a simple
I have a facebook connect button on this site here is the code <fb:login-button
I've inherited a medium sized project in which the main (batch) program is fed
Here is the scenario. I have a configurable product which has two attributes. However,
I have a medium sized application that containers two forms. When i open the
I have inherited a medium sized project that I would like to add an
I have a medium size data set, and here is an example taken from

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.