0

as I know, it is possible to setup a second entity manager in symfony. Ist there also the possiblity to use mysql an for special Bundles mongodb?

I found an example how to implement to dbs in symfony but I am not sure how to handle it with mysql and mongodb together:

http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/config.html

TheTom
  • 934
  • 2
  • 14
  • 40

2 Answers2

0

Yes you can use this two database-driver in one project

doctrine:
    dbal:
        connections:
            default:
                driver:   "%database_driver%"
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
                mapping_types:
                    enum: string
        # if using pdo_sqlite as your database driver, add the path in parameters.yml
        # e.g. database_path: "%kernel.root_dir%/data/data.db3"
        # path:     "%database_path%"

            dynamic:
                driver:   "%database_driver%"
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
                mapping_types:
                    enum: string
                wrapper_class: 'My\DoctrineBundle\Connection\ConnectionWrapper'

And you have to add the DoctrineBundle downlaoad and upload to your namesplace as defined in answer of this question Symfony connection wrapper

Community
  • 1
  • 1
Jignesh Vagh
  • 122
  • 1
  • 3
  • 18
  • I tryed it now by using following. So I enabled the automapping and so I can access to both dbs from everywhere. I am not sure if this is correct, but it works.. – TheTom May 21 '15 at 08:14
  • @TheTom If my answer you think right then please check as your answer it and upvote it – Jignesh Vagh May 26 '15 at 11:28
0
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true

doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: lead_base
    document_managers:
        default:
            auto_mapping: true
TheTom
  • 934
  • 2
  • 14
  • 40