Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple connection does not work #2811

Open
arisrais opened this issue Jun 20, 2018 · 1 comment
Open

Multiple connection does not work #2811

arisrais opened this issue Jun 20, 2018 · 1 comment

Comments

@arisrais
Copy link

arisrais commented Jun 20, 2018

Hi,

I tried to upgrade from FOSUserBundle 1.* to 2.* but the last version seem to not support multiple.

Example in my symfony config.yml file :

doctrine: orm: entity_managers: default: connection: default mappings : AppBundle: ~ FOSUserBundle: ~ reseau: connection: reseau mappings : AppBundle: ~ FOSUserBundle: ~ dbal: default_connection: default types: jsonb: Boldtrn\JsonbBundle\Types\JsonbArrayType json: Sonata\Doctrine\Types\JsonType connections: default: driver: pdo_pgsql host: '%database_host%' port: '%database_port%' dbname: '%database_name%' user: '%database_user%' password: '%database_password%' charset: UTF8 reseau: driver: pdo_pgsql host: '%database_host1%' port: '%database_port1%' dbname: '%database_name1%' user: '%database_user1%' password: '%database_password1%' charset: UTF8
`

When I try to call multiple connection in the same action, I got an error :
` $repod = $this->getDoctrine()->getRepository(User::class, 'default');
$user1 = $repod->findAll();

    $repor = $this->getDoctrine()->getRepository(User::class, 'reseau');
    $user2 = $repor->findAll();`

`

@olifrieda
Copy link

Looks like this is not an issue. You have duplicated the mapping:

doctrine:
    orm:
        entity_managers:
            default:
                connection: default
                mappings:
                    AppBundle: ~  <<<<<<<
                    FOSUserBundle: ~  <<<<<<<
            reseau:
                connection: reseau
                mappings :
                    AppBundle: ~  <<<<<<<
                    FOSUserBundle: ~  <<<<<<<

Remove one of the mappings e. g. like this:

doctrine:
   orm:
       entity_managers:
           default:
               connection: default
               mappings:
                   FOSUserBundle: ~
           reseau:
               connection: reseau
               mappings :
                   AppBundle: ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants