Merge pull request #556 from owncloud/postgres_insert_id
use lastval() to get the insert id in postgesql
This commit is contained in:
commit
f81321af3d
|
@ -353,6 +353,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" );
|
||||
|
@ -360,6 +366,7 @@ class OC_DB {
|
|||
}
|
||||
return self::$connection->lastInsertId($table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disconnect
|
||||
|
|
Loading…
Reference in New Issue