A: 

What you can do is this:

public function fetchByLoginFromMaster($login)
{
  $conn = ProjectConfiguration::getActive()->getMasterConnection();
  $q = Doctrine_Query::create($conn)
                ->from('User')
                ->where('login = ?', $login)
                ->fetchOne();
  return $q;
}
johnwards
Hi John,thanks for your reply. I tried out your suggestion. $conn now contains the master connection, which i testet with var_dump($conn->getName()).But still, the query is using the slave connection. I double-checked this by changing the password of the slave connection, which caused the request to fail.Thanks,Stephan
stijink
A: 

Hi,

i also tried to set the connection explicitly to master before doing the query. But again, the slave connection was used to execute the query.

I tried the following:

public function fetchByLoginFromMaster($login)
{
    $masterConn = ProjectConfiguration::getActive()->getMasterConnection();

    $this->setConnection($masterConn);

    $q = $this->createQuery()
                ->from('User')
                ->where('login = ?', $login)
                ->fetchOne();

    return $q;
}

Thank you, Stephan

stijink