* 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
*/
private static function getMDB2SchemaManager()
{
- return new \OC\DB\MDB2SchemaManager(self::getConnection());
+ return new \OC\DB\MDB2SchemaManager(\OC::$server->getDatabaseConnection());
}
/**
* @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();
}
/**
}
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
* @return string
*/
public static function getErrorMessage($error) {
- if (self::$connection) {
- return self::$connection->getError();
- }
- return '';
+ $connection = \OC::$server->getDatabaseConnection();
+ return $connection->getError();
}
/**
* @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();
}