contao / manager-bundle

[READ-ONLY] Contao Manager Bundle
GNU Lesser General Public License v3.0
17 stars 10 forks source link

defining a second database connection does not work #43

Closed fritzmg closed 7 years ago

fritzmg commented 7 years ago

Reproduction

  1. create an app/config/config.yml with
    doctrine:
    dbal:
        connections:
            second:
                driver:   pdo_mysql
                host:     '%second_database_host%'
                port:     '%second_database_port%'
                dbname:   '%second_database_name%'
                user:     '%second_database_user%'
                password: '%second_database_password%'
                charset:  UTF8
  2. provide the database parameters in your app/config/parameters.yml
    parameters:
    …
    second_database_host: …
    second_database_port: …
    second_database_user: …
    second_database_password: …
    second_database_name: …
  3. try to access the second database connection with
    \System::getContainer()->get('doctrine')->getConnection('second');

    The following error will occur:

    Doctrine ORM Connection named "second" does not exist.

    Same with

    \System::getContainer()->get('doctrine.dbal.second_connection');

    »

    You have requested a non-existent service "doctrine.dbal.second_connection". Did you mean this: "doctrine.dbal.default_connection"?
fritzmg commented 7 years ago

nvm, I had an additional config_dev.yml and thus the config.yml was simply not loaded. See https://github.com/contao/manager-bundle/issues/44