Steps to create Multiple database in symfony 2.0

298 Views Asked by At

I am using single database connection. Now I need to use two database connection. I need to know the steps to create two databases. I have lot of doubts. Generate entity commands are same what we using for single db connection or not.

Please explain step by step process for creating multiple entities and multiple db connection.

In /Symfony/app/config/config.yml i write the code:

doctrine:
dbal:
    default_connection:   default
    connections:
        default:
            driver:   %database_driver%
            host:     %database_host%
            port:     %database_port%
            dbname:   %database_name%
            user:     %database_user%
            password: %database_password%
            charset:  UTF8
        customer:
            driver:   %database_driver2%
            host:     %database_host2%
            port:     %database_port2%
            dbname:   %database_name2%
            user:     %database_user2%
            password: %database_password2%
            charset:  UTF8

orm:
    default_entity_manager:   default
    entity_managers:
        default:
            connection:       default
            mappings:
                dbBundle: ~
        client:
            connection:       client
            mappings:
                dbBundle: ~
1

There are 1 best solutions below

0
On

I found the answer : Add namespace before the bundle name

orm:
    default_entity_manager:   default
    entity_managers:
        default:
            connection:       default
            mappings:
                <Namespace>dbBundle: ~
        client:
            connection:       client
            mappings:
                 <Namespace>dbBundle: ~