Skip to content
Snippets Groups Projects
Commit 95340a9e authored by Robin Appelman's avatar Robin Appelman
Browse files

use lastval() to get the insert id in postgesql

parent 3688376a
No related branches found
No related tags found
No related merge requests found
......@@ -355,6 +355,12 @@ class OC_DB {
*/
public static function insertid($table=null) {
self::connect();
$type = OC_Config::getValue( "dbtype", "sqlite" );
if( $type == 'pgsql' ) {
$query = self::prepare('SELECT lastval() AS id');
$row = $query->execute()->fetchRow();
return $row['id'];
}else{
if($table !== null) {
$prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
$suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" );
......@@ -362,6 +368,7 @@ class OC_DB {
}
return self::$connection->lastInsertId($table);
}
}
/**
* @brief Disconnect
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment