| 897 | | if ( ! is_array($specifiedConnections)) { |
| 898 | | $specifiedConnections = (array) $specifiedConnections; |
| 899 | | } |
| 900 | | |
| 901 | | $manager = Doctrine_Manager::getInstance(); |
| 902 | | $connections = $manager->getConnections(); |
| 903 | | |
| 904 | | $results = array(); |
| 905 | | |
| 906 | | foreach ($connections as $name => $connection) { |
| 907 | | if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { |
| 908 | | continue; |
| 909 | | } |
| 910 | | |
| 911 | | $info = $manager->parsePdoDsn($connection->getOption('dsn')); |
| 912 | | $username = $connection->getOption('username'); |
| 913 | | $password = $connection->getOption('password'); |
| 914 | | |
| 915 | | // Make connection without database specified so we can create it |
| 916 | | $connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false); |
| 917 | | |
| 918 | | try { |
| 919 | | // Create database |
| 920 | | $connect->export->createDatabase($name); |
| 921 | | |
| 922 | | // Close the tmp connection with no database |
| 923 | | $manager->closeConnection($connect); |
| 924 | | |
| 925 | | // Close original connection |
| 926 | | $manager->closeConnection($connection); |
| 927 | | |
| 928 | | // Reopen original connection with newly created database |
| 929 | | $manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true); |
| 930 | | |
| 931 | | $results[$name] = true; |
| 932 | | } catch (Exception $e) { |
| 933 | | $results[$name] = false; |
| 934 | | } |
| 935 | | } |
| 936 | | |
| 937 | | return $results; |
| | 897 | return Doctrine_Manager::getInstance()->createDatabases($specifiedConnections); |
| 950 | | if ( ! is_array($specifiedConnections)) { |
| 951 | | $specifiedConnections = (array) $specifiedConnections; |
| 952 | | } |
| 953 | | |
| 954 | | $manager = Doctrine_Manager::getInstance(); |
| 955 | | |
| 956 | | $connections = $manager->getConnections(); |
| 957 | | |
| 958 | | $results = array(); |
| 959 | | |
| 960 | | foreach ($connections as $name => $connection) { |
| 961 | | if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) { |
| 962 | | continue; |
| 963 | | } |
| 964 | | |
| 965 | | try { |
| 966 | | $connection->export->dropDatabase($connection->getDatabaseName()); |
| 967 | | |
| 968 | | $results[$name] = true; |
| 969 | | } catch (Exception $e) { |
| 970 | | $results[$name] = false; |
| 971 | | } |
| 972 | | } |
| 973 | | |
| 974 | | return $results; |
| | 910 | return Doctrine_Manager::getInstance()->dropDatabases($specifiedConnections); |