Details
Description
If we manually set a connection on the Doctrine_Table instance Doctrine silently ignores it when creating a Doctrine_Query instance through createQuery method
$manager->setConnection($defaultConnection);
$table = Doctrine::getTable('Users')->setConnection($newConnection);
$table->createQuery(); // -> connection to $defaultConnection
The code:
public function createQuery($alias = '')
{
if ( ! empty($alias))
$class = $this->getAttribute(Doctrine_Core::ATTR_QUERY_CLASS);
return Doctrine_Query::create(null, $class) <-- fix too quick for a patch
-> return Doctrine_Query::create($this>_conn, $class)
>from($this>getComponentName() . $alias);
}
When using Table classes generated with the latest Symfony 1.4 version (1.4.8) the table gets bound to a specific connection, but Doctrine still uses the default connection.
Using the above mentioned quick fix - replacing $this->_conn with null - everything works as it should.