Is there any simple solution how to perform INSERT queries on one database and SELECT queries on another using Doctrine?
I'm trying to use Doctrine with Mysql replication...
Already found a solution, 2 classes need to be modified:
class Doctrine_Query, change preQuery method:
public function preQuery()
{
$doctrine_manager = Doctrine_Manager::getInstance();
if ($this->getType() == Doctrine_Query::SELECT) {
$this->_conn = $doctrine_manager->getConnection('slave');
} else {
$this->_conn = $doctrine_manager->getConnection('master');
}
}
class Doctrine_Record, update method save:
public function save(Doctrine_Connection $conn = null)
{
if ($conn === null) {
$conn = Doctrine_Manager::getInstance()->getConnection('master');
}
parent::save($conn);
}