From the start Doctrine has been designed to work with multiple connections. Unless separately specified Doctrine always uses the current connection for executing the queries. The following example uses openConnection() second argument as an optional connection alias.

openConnection(new PDO('dsn','username','password'), 'connection 1'); ?> "); ?>

For convenience Doctrine_Manager provides static method connection() which opens new connection when arguments are given to it and returns the current connection when no arguments have been speficied.

"); ?>

The current connection is the lastly opened connection.

openConnection(new PDO('dsn2','username2','password2'), 'connection 2'); \$manager->getCurrentConnection(); // \$conn2 ?>"); ?>

You can change the current connection by calling setCurrentConnection().

setCurrentConnection('connection 1'); \$manager->getCurrentConnection(); // \$conn ?> "); ?>

You can iterate over the opened connection by simple passing the manager object to foreach clause. This is possible since Doctrine_Manager implements special IteratorAggregate interface.

"); ?>