summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-09-10 13:33:59 +0200
committerRobin Appelman <icewind@owncloud.com>2014-10-22 12:29:53 +0200
commite6f6cdd19fe2b9726fd85a684b9f624e509e3994 (patch)
treeabd5ddef6d789bda849950469734596dafb793b9
parent2ae6a0d96d45e2270a9c06bbfc91d1733fa9fce3 (diff)
downloadnextcloud-server-e6f6cdd19fe2b9726fd85a684b9f624e509e3994.tar.gz
nextcloud-server-e6f6cdd19fe2b9726fd85a684b9f624e509e3994.zip
Bit more cleanup
-rw-r--r--lib/private/db.php35
-rw-r--r--lib/private/db/mdb2schemamanager.php5
-rw-r--r--lib/public/idbconnection.php8
3 files changed, 21 insertions, 27 deletions
diff --git a/lib/private/db.php b/lib/private/db.php
index 59d61ffa297..9b904a1518f 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -41,19 +41,6 @@ class DatabaseException extends Exception {
* Doctrine with some adaptions.
*/
class OC_DB {
- /**
- * @var \OC\DB\Connection $connection
- */
- static private $connection; //the preferred connection to use, only Doctrine
-
- /**
- * The existing database connection is closed and connected again
- */
- public static function reconnect() {
- $connection = \OC::$server->getDatabaseConnection();
- $connection->close();
- $connection->connect();
- }
/**
* @return \OCP\IDBConnection
@@ -69,7 +56,7 @@ class OC_DB {
*/
private static function getMDB2SchemaManager()
{
- return new \OC\DB\MDB2SchemaManager(self::getConnection());
+ return new \OC\DB\MDB2SchemaManager(\OC::$server->getDatabaseConnection());
}
/**
@@ -282,17 +269,17 @@ class OC_DB {
* @param string $tableName the table to drop
*/
public static function dropTable($tableName) {
-
+ $connection = \OC::$server->getDatabaseConnection();
$tableName = OC_Config::getValue('dbtableprefix', 'oc_' ) . trim($tableName);
- self::$connection->beginTransaction();
+ $connection->beginTransaction();
- $platform = self::$connection->getDatabasePlatform();
+ $platform = $connection->getDatabasePlatform();
$sql = $platform->getDropTableSQL($platform->quoteIdentifier($tableName));
- self::$connection->query($sql);
+ $connection->executeQuery($sql);
- self::$connection->commit();
+ $connection->commit();
}
/**
@@ -332,8 +319,8 @@ class OC_DB {
}
public static function getErrorCode($error) {
- $code = self::$connection->errorCode();
- return $code;
+ $connection = \OC::$server->getDatabaseConnection();
+ return $connection->errorCode();
}
/**
* returns the error code and message as a string for logging
@@ -342,10 +329,8 @@ class OC_DB {
* @return string
*/
public static function getErrorMessage($error) {
- if (self::$connection) {
- return self::$connection->getError();
- }
- return '';
+ $connection = \OC::$server->getDatabaseConnection();
+ return $connection->getError();
}
/**
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index a07c421b9b8..fb3230e93af 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -21,7 +21,7 @@ class MDB2SchemaManager {
protected $conn;
/**
- * @param \OC\DB\Connection $conn
+ * @param \OCP\IDBConnection $conn
*/
public function __construct($conn) {
$this->conn = $conn;
@@ -154,7 +154,8 @@ class MDB2SchemaManager {
$this->conn->commit();
if ($this->conn->getDatabasePlatform() instanceof SqlitePlatform) {
- \OC_DB::reconnect();
+ $this->conn->close();
+ $this->conn->connect();
}
return true;
}
diff --git a/lib/public/idbconnection.php b/lib/public/idbconnection.php
index d7cce2e818b..ce17d293e86 100644
--- a/lib/public/idbconnection.php
+++ b/lib/public/idbconnection.php
@@ -150,4 +150,12 @@ interface IDBConnection {
* @return string The quoted parameter.
*/
public function quote($input, $type = \PDO::PARAM_STR);
+
+ /**
+ * Gets the DatabasePlatform instance that provides all the metadata about
+ * the platform this driver connects to.
+ *
+ * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform.
+ */
+ public function getDatabasePlatform();
}