diff options
Diffstat (limited to 'lib/private/db.php')
-rw-r--r-- | lib/private/db.php | 69 |
1 files changed, 2 insertions, 67 deletions
diff --git a/lib/private/db.php b/lib/private/db.php index a4a7b7d17d4..d47b7d4f31a 100644 --- a/lib/private/db.php +++ b/lib/private/db.php @@ -36,13 +36,6 @@ class OC_DB { /** - * @return \OCP\IDBConnection - */ - static public function getConnection() { - return \OC::$server->getDatabaseConnection(); - } - - /** * get MDB2 schema manager * * @return \OC\DB\MDB2SchemaManager @@ -158,42 +151,6 @@ class OC_DB { } /** - * gets last value of autoincrement - * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix - * @return string id - * @throws \OC\DatabaseException - * - * \Doctrine\DBAL\Connection lastInsertId - * - * Call this method right after the insert command or other functions may - * cause trouble! - */ - public static function insertid($table=null) { - return \OC::$server->getDatabaseConnection()->lastInsertId($table); - } - - /** - * Start a transaction - */ - public static function beginTransaction() { - return \OC::$server->getDatabaseConnection()->beginTransaction(); - } - - /** - * Commit the database changes done during a transaction that is in progress - */ - public static function commit() { - return \OC::$server->getDatabaseConnection()->commit(); - } - - /** - * Rollback the database changes done during a transaction that is in progress - */ - public static function rollback() { - return \OC::$server->getDatabaseConnection()->rollback(); - } - - /** * saves database schema to xml file * @param string $file name of file * @param int $mode @@ -254,15 +211,6 @@ class OC_DB { } /** - * drop a table - the database prefix will be prepended - * @param string $tableName the table to drop - */ - public static function dropTable($tableName) { - $connection = \OC::$server->getDatabaseConnection(); - $connection->dropTable($tableName); - } - - /** * remove all tables defined in a database structure xml file * @param string $file the xml file describing the tables */ @@ -272,15 +220,6 @@ class OC_DB { } /** - * check if a result is an error, works with Doctrine - * @param mixed $result - * @return bool - */ - public static function isError($result) { - //Doctrine returns false on error (and throws an exception) - return $result === false; - } - /** * check if a result is an error and throws an exception, works with \Doctrine\DBAL\DBALException * @param mixed $result * @param string $message @@ -288,20 +227,16 @@ class OC_DB { * @throws \OC\DatabaseException */ public static function raiseExceptionOnError($result, $message = null) { - if(self::isError($result)) { + if($result === false) { if ($message === null) { $message = self::getErrorMessage(); } else { $message .= ', Root cause:' . self::getErrorMessage(); } - throw new \OC\DatabaseException($message, self::getErrorCode()); + throw new \OC\DatabaseException($message, \OC::$server->getDatabaseConnection()->errorCode()); } } - public static function getErrorCode() { - $connection = \OC::$server->getDatabaseConnection(); - return $connection->errorCode(); - } /** * returns the error code and message as a string for logging * works with DoctrineException |