Looking for examples of cross-library operations under symfony 2
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 16:45:11
0
1
433

Looking for examples of cross-library operations under symfony 2

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(1)
给我你的怀抱

First configure multiple connections and corresponding managers:

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

    orm:
        default_entity_manager:   db1
        entity_managers:
            db1:
                connection:       db1
                mappings:
                    UsingDb1Bundle: ~
            db2:
                connection:       db2
                mappings:
                    UsingDb2Bundle: ~

The above configuration is to let the two bundles use different managers respectively. If you want to use a manager in a bundle, you can:

    entity_managers:
        db1:
            connection:       db1
            mappings:
                db1:
                    dir:      Path/To/EntityFolder1
        db2:
            connection:       db2
            mappings:
                db2:
                    dir:      Path/To/EntityFolder2

You have to separate entities into different folders.

With multiple managers, the use is no different from a single one. Pay attention to handing the object to the corresponding manager for processing.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!