aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/ConnectionAdapter.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/ConnectionAdapter.php')
-rw-r--r--lib/private/DB/ConnectionAdapter.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/private/DB/ConnectionAdapter.php b/lib/private/DB/ConnectionAdapter.php
index a53c7ecd994..e27c98194fb 100644
--- a/lib/private/DB/ConnectionAdapter.php
+++ b/lib/private/DB/ConnectionAdapter.php
@@ -27,6 +27,10 @@ namespace OC\DB;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
+use Doctrine\DBAL\Platforms\MySQLPlatform;
+use Doctrine\DBAL\Platforms\OraclePlatform;
+use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use OC\DB\Exceptions\DbalException;
use OCP\DB\IPreparedStatement;
@@ -87,7 +91,7 @@ class ConnectionAdapter implements IDBConnection {
public function lastInsertId(string $table): int {
try {
- return (int)$this->inner->lastInsertId($table);
+ return $this->inner->lastInsertId($table);
} catch (Exception $e) {
throw DbalException::wrap($e);
}
@@ -242,4 +246,19 @@ class ConnectionAdapter implements IDBConnection {
public function getInner(): Connection {
return $this->inner;
}
+
+ public function getDatabaseProvider(): string {
+ $platform = $this->inner->getDatabasePlatform();
+ if ($platform instanceof MySQLPlatform) {
+ return IDBConnection::PLATFORM_MYSQL;
+ } elseif ($platform instanceof OraclePlatform) {
+ return IDBConnection::PLATFORM_ORACLE;
+ } elseif ($platform instanceof PostgreSQLPlatform) {
+ return IDBConnection::PLATFORM_POSTGRES;
+ } elseif ($platform instanceof SqlitePlatform) {
+ return IDBConnection::PLATFORM_SQLITE;
+ } else {
+ throw new \Exception('Database ' . $platform::class . ' not supported');
+ }
+ }
}