简体   繁体   中英

Doctrine 1.2 - How to connect 2 databases

I have two databases on my server, I need to connect these two databases using Doctrine 1.2 so I use both as a single database, creating models and everything.

In my bootstrap.php file I have:

Doctrine_Manager::connection('mysql://safonizer-user:e41b74468b2c867f06759c5e7255c838@localhost/safonizer','padrao');
Doctrine_Manager::connection('mysql://safonizer-user:e41b74468b2c867f06759c5e7255c838@localhost/padraosaude','padrao1');

But does not work the way I want ... someone can help me do this? It has to do this and how?

Thank you in advance.

Have you read the Doctrine 1.2 documentation on connections ? That makes two particular comments that you should consider (it's not clear from your "...does not work the way I want..." in your original question what problem you are encountering):

  1. As per the documentation's "Current Connection" section, note that "The current connection is the last opened connection."

  2. To change the current connection use Doctrine_Manager::setCurrentConnection() (in your case using padrao or pardrao1 as parameters).

If you are interested in queries that span the two databases, you should read the Doctrine 1.2 documentation on cross database joins .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM