문제

With Doctrine in Symfony2 there is a simple way to start a project with reverse-engineered Entities created from existing database schema. It is quite well documented here. There is not mentioned how to reverse-engineer data from a non-default database when using multiple databases (which is documented here).

I found the solution here, it works like this:

php app/console doctrine:mapping:convert --em="troller" --from-database yml ./src/NAMESPACE/NAMEBundle/Resources/config/doctrine/metadata/orm

However, I'm just getting the exception as if the second entity manager didn't exist. Even though I have config.yml according to docs.

[InvalidArgumentException]                            
Doctrine ORM Manager named "troller" does not exist.

Any ideas?

도움이 되었습니까?

해결책

Did you specify an entity manager with "troller" name?

You can do this with a snippet of code like this (into app/config/config.yml file)

orm:
  default_entity_manager:   default
  entity_managers:
    default:
      connection:       default
      mappings:
        AcmeDemoBundle: ~
        AcmeStoreBundle: ~
    troller:
      connection:       troller
      mappings:
        YourTrollerBundle: ~

In this example, you've defined two entity managers called default and troller. The default entity manager manages entities in the AcmeDemoBundle and AcmeStoreBundle, while the troller entity manager manages entities in the YourTrollerBundle. You've also defined two connections, one for each entity manager.

Obiously define a new connection and entity manager, isn't enaugh: you have to specify "connection parameters" also (like db name, user, password, driver, and so on)

troller:
  driver:   "%database_driver2%"
  host:     "%database_host2%"
  port:     "%database_port2%"
  dbname:   "%database_name2%"
  user:     "%database_user2%"
  password: "%database_password2%"
  charset:  UTF8
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top