Unable to change doctrine mix

I am trying to create a script that imports elements from a production database into a local one, but I am having problems switching production of the connection form to local.

Doctrine_Manager::getInstance()->setCurrentConnection('prod-slave');
// execute query to get data from production, confirm it worked

Doctrine_Manager::getInstance()->setCurrentConnection('local');
// insert data into local database

When I run this, I get this error:

PHP Fatal error: throw a "Doctrine_Connection_Mysql_Exception" exception with the message "SQLSTATE [HY000]: General error: 1290 MySQL server is running with -read-only, so it cannot execute this statement in ...

If I close the connection with prod-slave before setting it to local, I get:

PHP Fatal error: throw a "Doctrine_Manager_Exception" exception with the message "Unknown connection: prod-slave" in ...

, , ( , ).

:

Doctrine_Manager::connection('mysql://path');

: 1.2.3

Symfony: 1.3.9

.

+4
2

, , . , , .

Doctrine_Manager::getInstance()->bindComponent($component, 'local'); .

0

setCurrentConnection getConnection

$slave = Doctrine_Manager::getInstance()->getConnection('prod-slave');
$result1 = $slave->execute($some_sql);

$local = Doctrine_Manager::getInstance()->getConnection('local');
$result2 = $local->execute($some_other_sql);

symfony 1.4.

, config/databases.yml prod-slave . . ( , )

0

Source: https://habr.com/ru/post/1568347/


All Articles