Changeset 2951 for trunk/lib/Doctrine.php
- Timestamp:
- 10/20/07 20:14:30 (15 months ago)
- Files:
-
- 1 modified
-
trunk/lib/Doctrine.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Doctrine.php
r2943 r2951 735 735 * @return void 736 736 */ 737 public static function createDatabases($specifiedConnections )737 public static function createDatabases($specifiedConnections = array()) 738 738 { 739 739 if (!is_array($specifiedConnections)) { … … 741 741 } 742 742 743 $connections = Doctrine_Manager::getInstance()->getConnections(); 743 $manager = Doctrine_Manager::getInstance(); 744 $connections = $manager->getConnections(); 744 745 745 746 foreach ($connections as $name => $connection) { … … 748 749 } 749 750 750 $connection->export->createDatabase($name); 751 $info = $manager->parsePdoDsn($connection->getOption('dsn')); 752 $username = $connection->getOption('username'); 753 $password = $connection->getOption('password'); 754 755 // Make connection without database specified so we can create it 756 $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); 757 758 try { 759 // Create database 760 $connect->export->createDatabase($name); 761 762 // Close the tmp connection with no database 763 $manager->closeConnection($connect); 764 765 // Close original connection 766 $manager->closeConnection($connection); 767 768 // Reopen original connection with newly created database 769 $manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true); 770 } catch (Exception $e) { 771 772 } 751 773 } 752 774 } … … 766 788 } 767 789 768 $connections = Doctrine_Manager::getInstance()->getConnections(); 790 $manager = Doctrine_Manager::getInstance(); 791 792 $connections = $manager->getConnections(); 769 793 770 794 foreach ($connections as $name => $connection) { … … 773 797 } 774 798 775 $connection->export->dropDatabase($name); 799 try { 800 $connection->export->dropDatabase($name); 801 } catch (Exception $e) { 802 803 } 776 804 } 777 805 }