1
0
mirror of synced 2024-12-15 15:46:02 +03:00
doctrine2/manual/codes/Working with objects - Component overview - Manager - Managing connections.php

26 lines
573 B
PHP
Raw Normal View History

2006-07-24 01:08:06 +04:00
<?php
// Doctrine_Manager controls all the connections
2006-07-24 01:08:06 +04:00
$manager = Doctrine_Manager::getInstance();
// open first connection
2006-07-24 01:08:06 +04:00
$conn = $manager->openConnection(new PDO("dsn","username","password"), "connection 1");
2006-07-24 01:08:06 +04:00
// open second connection
2006-07-24 01:08:06 +04:00
$conn2 = $manager->openConnection(new PDO("dsn2","username2","password2"), "connection 2");
2006-07-24 01:08:06 +04:00
$manager->getCurrentConnection(); // $conn2
2006-07-24 01:08:06 +04:00
$manager->setCurrentConnection("connection 1");
2006-07-24 01:08:06 +04:00
$manager->getCurrentConnection(); // $conn
2006-07-24 01:08:06 +04:00
// iterating through connections
2006-07-24 01:08:06 +04:00
foreach($manager as $conn) {
2006-07-24 01:08:06 +04:00
}
?>