1

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?

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

It helps me too, btw if you may not set specific mapping option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.