propelorm / PropelBundle

PropelBundle for Symfony.
http://propelorm.org/Propel/documentation/#working-with-symfony2
180 stars 156 forks source link

Slave connection is not working. #462

Closed pshanoop closed 2 years ago

pshanoop commented 7 years ago

I tried to add a slave connection using yml config

propel:
    database:
        connections:
            default:
                adapter:    pdo_mysql
                user:       '%database_user%'
                password:   '%database_password%'
                dsn:        pdo_mysql:host=%database_host%;dbname=%database_name%;charset=UTF8
                slaves:
                #ReadOnlyConnection detail
                  - dsn:        pdo_mysql:host=%db.livecopy.host%;dbname=%db.livecopy.db%;charset=UTF8
#Can be moved to parameters. Used in huge data export and db copy corn.
            livecopy:
                adapter:    pdo_mysql
                user:       "%db.livecopy.user%"
                password:   "%db.livecopy.password%"
                dsn:        pdo_mysql:host=%db.livecopy.host%;dbname=%db.livecopy.db%;charset=UTF8
    runtime:
        defaultConnection: default
        connections:       [ default, livecopy ]
    generator:
        defaultConnection: default

I'm getting error like this

PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 2 passed to Propel\Runtime\Connection\ConnectionFactory::create() must implement interface Propel\Runtime\Adapter\AdapterInterface, null given, called in *****/vendor/propel/propel/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php on line 143 in *****/vendor/propel/propel/src/Propel/Runtime/Connection/ConnectionFactory.php:33
Stack trace:
#0 *****/vendor/propel/propel/src/Propel/Runtime/Connection/ConnectionManagerMasterSlave.php(143): Propel\Runtime\Connection\ConnectionFactory::create(Array, NULL)
#1 *****/vendor/propel/propel-bundle/PropelBundle.php(99): Propel\Runtime\Connection\ConnectionManagerMasterSlave->getWriteConnection()
#2 *****/vendor/propel/propel-bundle/PropelBundle.php(37): Propel\Bundle\PropelBundle\PropelBundle->configureLoggin in ******/vendor/propel/propel/src/Propel/Runtime/Connection/ConnectionFactory.php on line 33

But no issue if remove slave things is working perfect.

Update to latest version in master for propel and for propel-bundle