summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/db.php11
-rw-r--r--lib/private/db/connection.php13
-rw-r--r--lib/public/idbconnection.php7
3 files changed, 21 insertions, 10 deletions
diff --git a/lib/private/db.php b/lib/private/db.php
index f8015133682..9387cc48457 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -263,16 +263,7 @@ class OC_DB {
*/
public static function dropTable($tableName) {
$connection = \OC::$server->getDatabaseConnection();
- $tableName = OC_Config::getValue('dbtableprefix', 'oc_' ) . trim($tableName);
-
- $connection->beginTransaction();
-
- $platform = $connection->getDatabasePlatform();
- $sql = $platform->getDropTableSQL($platform->quoteIdentifier($tableName));
-
- $connection->executeQuery($sql);
-
- $connection->commit();
+ $connection->dropTable($tableName);
}
/**
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index a6cdf858899..e2d90c8fc82 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -164,6 +164,19 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection {
return $msg;
}
+ /**
+ * Drop a table from the database if it exists
+ *
+ * @param string $table table name without the prefix
+ */
+ public function dropTable($table) {
+ $table = $this->tablePrefix . trim($table);
+ $schema = $this->getSchemaManager();
+ if($schema->tablesExist(array($table))) {
+ $schema->dropTable($table);
+ }
+ }
+
// internal use
/**
* @param string $statement
diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php
index ce17d293e86..bc563d20b42 100644
--- a/lib/public/idbconnection.php
+++ b/lib/public/idbconnection.php
@@ -158,4 +158,11 @@ interface IDBConnection {
* @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
*/
public function getDatabasePlatform();
+
+ /**
+ * Drop a table from the database if it exists
+ *
+ * @param string $table
+ */
+ public function dropTable($table);
}