Skip to content

Instantly share code, notes, and snippets.

@nickvergessen
Created September 20, 2013 14:58
Show Gist options
  • Save nickvergessen/6638810 to your computer and use it in GitHub Desktop.
Save nickvergessen/6638810 to your computer and use it in GitHub Desktop.
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