- Timestamp:
- 07/19/08 13:12:59 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/docs/manual/de/connection-management/managing-connections.txt
r4674 r4695 1 From the start Doctrine has been designed to work with multiple connections. Unless separately specified Doctrine always 2 uses the current connection for executing the queries. The following example uses {{openConnection()}} second argument as 3 an optional connection alias. 1 Von Beginn an wurde Doctrine so entworfen, dass es mit mehreren DB-Verbindungen arbeitet. Außer Sie geben die Verbindung explizit an, benutzt Doctrine immer die dezeit aktuelle Verbindung für Anfragen. 2 Das folgende Bespiel zeigt, wie man eine optionale DB-Verbindung als 2. Funktionsparameter {{openConnection()}} übergibt: 4 3 5 4 <code type="php"> 6 // Doctrine_Manager controls all the connections5 // Doctrine_Manager verwaltet alle Verbindungen 7 6 8 7 $manager = Doctrine_Manager::getInstance(); 9 8 10 // open first connection9 // erste Verbindung öffnen 11 10 12 11 $conn = $manager->openConnection('mysql://username:password@localhost/test', 'connection 1'); 13 12 </code> 14 13 15 For convenience {{Doctrine_Manager}} provides static method {{connection()}} which opens new connection when arguments 16 are given to it and returns the current connection when no arguments have been speficied. 14 Zur Vereinfachung stellt {{Doctrine_Manager}} die statische Methode {{connection()}} bereit. Beim Aufruf mit Parametern öffnet sie eine neue Verbindung, ohne Parameter liefert sie die aktuelle Vebindung zurück. 17 15 18 16 <code type="php"> 19 // open first connection17 // erste Verbindung öffnen 20 18 21 19 $conn = Doctrine_Manager::connection('mysql://username:password@localhost/test', 'connection 1'); … … 26 24 </code> 27 25 28 The current connection is the lastly opened connection. 26 Die aktuelle Verbindung ist immer die zuletzt geöffnete. 27 29 28 30 29 <code type="php"> 31 // open second connection30 // zweite Verbindung öffnen 32 31 33 32 $conn2 = $manager->openConnection('mysql://username2:password2@localhost/test2', 'connection 2'); … … 36 35 </code> 37 36 38 You can change the current connection by calling {{setCurrentConnection()}}. 39 37 Ändern Sie die benutzte Verbindung durch Aufrufen von {{setCurrentConnection()}}. 40 38 <code type="php"> 41 39 $manager->setCurrentConnection('connection 1'); … … 44 42 </code> 45 43 46 You can iterate over the opened connection by simple passing the manager object to foreach clause. This is possible 47 since {{Doctrine_Manager}} implements special {{IteratorAggregate}} interface. 44 45 Da {{Doctrine_Manager}} das {{IteratorAggregate}} Interface implementiert, können sie ganz einfach mit foreach über das Manager Objekt iterieren, um auf die geöffneten Verbindungen zuzugreifen: 48 46 49 47 <code type="php">