Created
September 20, 2013 14:58
-
-
Save nickvergessen/6638810 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
$this->connect(false); | |
try | |
{ | |
$this->pdo->exec('DROP DATABASE ' . $this->config['dbname']); | |
try | |
{ | |
$this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']); | |
} | |
catch (PDOException $e) | |
{ | |
throw new Exception("Unable to re-create database: {$e->getMessage()}"); | |
} | |
} | |
catch (PDOException $e) | |
{ | |
try | |
{ | |
// try to delete all tables if dropping the database was not possible. | |
foreach ($this->get_tables() as $table) | |
{ | |
$this->pdo->exec('DROP TABLE ' . $table); | |
} | |
$this->purge_extras(); | |
} | |
catch (PDOException $e) | |
{ | |
try | |
{ | |
$this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']); | |
} | |
catch (PDOException $e) | |
{ | |
throw new Exception("Unable to re-create database: {$e->getMessage()}"); | |
} | |
} | |
} | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment