From 27ae95af91a3ad71e0d0139cad0ba022b0ffd924 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 13 Jun 2007 21:41:20 +0000 Subject: [PATCH] dropDatabase() added --- lib/Doctrine/Export/Sqlite.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/Doctrine/Export/Sqlite.php b/lib/Doctrine/Export/Sqlite.php index 5778da787..eaca2a44a 100644 --- a/lib/Doctrine/Export/Sqlite.php +++ b/lib/Doctrine/Export/Sqlite.php @@ -33,6 +33,26 @@ Doctrine::autoload('Doctrine_Export'); */ class Doctrine_Export_Sqlite extends Doctrine_Export { + /** + * drop an existing database + * + * @param string $name name of the database that should be dropped + * @throws Doctrine_Export_Exception if the database file does not exist + * @throws Doctrine_Export_Exception if something failed during the removal of the database file + * @return void + */ + public function dropDatabase($name) + { + $databaseFile = $this->conn->formatter->getDatabaseFile($name); + if (!@file_exists($databaseFile)) { + throw new Doctrine_Export_Exception('database does not exist'); + } + $result = @unlink($database_file); + if ( ! $result) { + throw new Doctrine_Export_Exception('could not remove the database file'); + } + } + /** * Get the stucture of a field into an array *