Multiple databases support in Symfony

后端 未结 3 595
不知归路
不知归路 2020-12-17 05:31

I am using Propel as my DAL for my Symfony project. I can\'t seem to get my application to work across two or more databases.

Here\'s my schema.yml:

         


        
相关标签:
3条回答
  • 2020-12-17 05:50

    I got this issue working! The most important thing is you must name your schema according to %dbname%.schema.yml. In this way Symfony will be able to assign the ymls to the correct database.

    0 讨论(0)
  • 2020-12-17 06:00

    You can also use Propel::getConnection('db2') to manually retrieve a connection.

    Just have in mind that what you call "db1", "db2" are the connection names. You can have several connections to a same database with various login/permissions (like read only etc.).

    It's very good for testing purpose: you can do it with the same connection name with a different database. No way to crash your production database with that :)

    0 讨论(0)
  • 2020-12-17 06:02

    Also when running the task you should specify the connection for example:

    symfony propel:build-all-load --connection=my_connection
    

    This worked for me, hope it helps.

    0 讨论(0)
提交回复
热议问题