0

I'm creating a project in symfony, but suddenly I'm having trouble when there are two databases for my project like this:

all:  gapi_1:
class: sfDoctrineDatabase
param:
  dsn:      mysql:host=localhost;dbname=gapi_1
  username: root
  password:

 gapi_2:
class: sfDoctrineDatabase
param:
  dsn:      mysql:host=localhost;dbname=gapi_2
  username: root
  password:

I'm very confused about how to access database in my action pages. Please help me to access the symfony multiple database in same action.class.php file.

2
  • did you have a look at the answer given in this thread: stackoverflow.com/questions/733224/…? Commented Sep 30, 2011 at 7:01
  • thanks for solution link, my database is created successfully but i unable to access them. So, please help me to access this database in action.class.php Commented Sep 30, 2011 at 7:20

1 Answer 1

0
Doctrine_Manager::getInstance()->setCurrentConnection('gapi_1');

and

Doctrine_Manager::getInstance()->setCurrentConnection('gapi_2');

outside of the context i think like that (not sure):

$databaseManager = new sfDatabaseManager($this->configuration);
$db1 = $databaseManager->getDatabase('gapi_1');
$db1->getDoctrineConnection();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.