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):
As per the documentation’s “Current Connection” section, note that “The current connection is the last opened connection.”
To change the current connection use
Doctrine_Manager::setCurrentConnection()(in your case usingpadraoorpardrao1as parameters).If you are interested in queries that span the two databases, you should read the Doctrine 1.2 documentation on cross database joins.