2

i use symfony2 with FOSuserBundle.

i need 2 database connections one for Usermanagement and another remote database connection.

how can i use them simultaneously?

can parameters.ini file have double database params? sth like this

[parameters] database_driver="pdo_mysql"
database_host="localhost"
database_port=""
database_name="symfony"
database_user="root"
database_password=""
database2_driver="pdo_mysql"
database2_host="remote_ip"
database2_port=""
database2_name="symfonydb2"
database2_user="root"
database2_password=""

1

1 Answer 1

2

To answer your questions:

how can i use them simultaneously?

Like @vbergae said, just take a look at How to work with Multiple Entity Managers

can parameters.ini file have double database params?

For sure, you'll just have to reference in your config file it like this:

  • %database2_driver%
  • %database2_host%
  • %database2_port%
  • %database2_name%
  • %database2_user%
  • %database2_password%
Sign up to request clarification or add additional context in comments.

2 Comments

i just want to use pure sql query how is it possible?
symfony2 being model agnostic you can use whatever you judge relevant to access you datas. But for separation concern leave your pure SQL queries in your model, don't do this in controller nor in views (Doh!)

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.