Commit d5c91081 authored by jwage's avatar jwage

-

parent 689a4c6f
......@@ -1402,20 +1402,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* createDatabase
*
* @return void
* Method for creating the database for the connection instance
*
* @return mixed Will return an instance of the exception thrown if the create database fails, otherwise it returns a string detailing the success
*/
public function createDatabase()
{
try {
if ( ! $dsn = $this->getOption('dsn')) {
throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$manager = $this->getManager();
$info = $manager->parsePdoDsn($this->getOption('dsn'));
$info = $manager->parsePdoDsn($dsn);
$username = $this->getOption('username');
$password = $this->getOption('password');
// Make connection without database specified so we can create it
$connect = $manager->openConnection(new PDO($info['scheme'] . ':host=' . $info['host'], $username, $password), 'tmp_connection', false);
try {
// Create database
$connect->export->createDatabase($info['dbname']);
......@@ -1437,12 +1443,18 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
/**
* dropDatabase
*
* @return void
* Method for dropping the database for the connection instance
*
* @return mixed Will return an instance of the exception thrown if the drop database fails, otherwise it returns a string detailing the success
*/
public function dropDatabase()
{
try {
$info = $this->getManager()->parsePdoDsn($this->getOption('dsn'));
if ( ! $dsn = $this->getOption('dsn')) {
throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$info = $this->getManager()->parsePdoDsn($dsn);
$this->export->dropDatabase($info['dbname']);
......
......@@ -90,16 +90,6 @@ class Doctrine_Connection_Mysql extends Doctrine_Connection_Common
parent::__construct($manager, $adapter);
}
/**
* returns the name of the connected database
*
* @return string
*/
public function getDatabaseName()
{
return $this->fetchOne('SELECT DATABASE()');
}
/**
* Set the charset on the current connection
*
......
......@@ -103,9 +103,11 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
public function createDatabase()
{
try {
$manager = $this->getManager();
if ( ! $dsn = $this->getOption('dsn')) {
throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$info = $manager->parseDsn($this->getOption('dsn'));
$info = $this->getManager()->parseDsn($dsn);
$this->export->createDatabase($info['database']);
......@@ -123,7 +125,11 @@ class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
public function dropDatabase()
{
try {
$info = $this->getManager()->parseDsn($this->getOption('dsn'));
if ( ! $dsn = $this->getOption('dsn')) {
throw new Doctrine_Connection_Exception('You must create your Doctrine_Connection by using a valid Doctrine style dsn in order to use the create/drop database functionality');
}
$info = $this->getManager()->parseDsn($dsn);
$this->export->dropDatabase($info['database']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment