Linking doctrine with db

I am about to run a project in symphony doctrine, but I need to establish a connection to multiple databases. One of them is an existing database (SQL SERVER) that cannot be mapped to the ORM. Is there a way to connect to this db with another db that does NOT show up in the doctrine and usually works with controllers?

+3


source to share


1 answer


I am developing sf2 multi-database application with orrine doctrine2 display.

We are using intellectsoft-uk / MssqlBundle

Our configuration:

config.yml



# Doctrine Configuration
doctrine:
    dbal:
        default_connection: acme_mysql
        connections:
            acme_mysql:
                host: %acme_mysql_database_host%
                port: %acme_mysql_database_port%
                dbname: %acme_mysql_database_name%
                user: %acme_mysql_database_user%
                password: %acme_mysql_database_password%
                charset:  UTF8
            acme_slqsrv:
                driver:         sqlsrv
                driver_class:   \Realestate\MssqlBundle\Driver\PDODblib\Driver
                host: %acme_slqsrv%
                port: %acme_slqsrv%
                dbname: %acme_slqsrv%
                user: %acme_slqsrv%
                password: %acme_slqsrv%
                charset:  UTF8
orm: #optional if you want to map some entity in doctrine2
    auto_generate_proxy_classes: %kernel.debug%
    default_entity_manager: acme_mysql
    entity_managers:
        em_mysql:
            connection: acme_mysql
            mappings:
                AcmeMysqlBundle: ~
        em_sqlsrv:
            connection: acme_sqlsrv
            mappings:
                AcmeSqlSrvBundle: ~

      

This configuration allows you to take an instance of the connection in the controller / service and use it to access the database and execute stored procedures, etc.

Hope for this help

+2


source