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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:50:36+00:00 2026-05-17T02:50:36+00:00

Summary: I want to be able to run a query against an external database

  • 0

Summary:

I want to be able to run a query against an external database to grab some needed data at the time the user logs in. I don’t want this site to do anything else with the external database. Long term, it may need to be able to push data back, but specifically, I don’t want symfony to try to build the schema for the external db, it should just leave it alone and allow a connection from time to time.

Details:

I’m trying to create a temporary connection to a database of another symfony application and I can’t seem to figure out how to do it.

I have an existing symfony site that is set up and running. I’m trying to create a sort of management system for users of this main site. The management system will have separate deployments for each users that opts in to it, so it will also have its own database associated with it. However, this management systems needs access to 2 or 3 tables from the main sites system.

I’ve tried adding separate entries in databases.yml in the management system to create connections to both databases, however whenever I build all, it wants to put my schema in both databases.

The best idea I have come up with is placing connection: management in all my tables for the management system, and also place connection: main_site in all the tables from the main site. However, that would require me to maintain the yml files both in the management system and on the main site to make sure they stayed current with each other.

I hope that was even slightly clear.

Thanks for the help 😀

  • 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-17T02:50:36+00:00Added an answer on May 17, 2026 at 2:50 am

    For a temporary connection without the ability to use DQL on the remote site, just open the connection via Doctrine_Manager:

    $conn = Doctrine_Manager::getInstance()->openConnection('mysql://username:password@localhost/database', 'connection 2', false);
    

    Make sure the 3rd argument is false so that it doesn’t become the current connection. You can then run queries on the connection using PDO:

    $conn->exec('SELECT * FROM table WHERE conditon = ?', array('value'));
    

    If you want to be able to use DQL and the remote schema, you’ll have to do it the way you outlined: define two connections and maintain the schema in both places (your version control should be able to handle this).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.