diff options
author | Brice Maron <brice@bmaron.net> | 2011-10-29 11:40:48 +0200 |
---|---|---|
committer | Brice Maron <brice@bmaron.net> | 2011-10-29 11:40:48 +0200 |
commit | e533e82bc9526ef9869b20e99b745c210348218f (patch) | |
tree | 6ce0621f070c3888e1c34b68b7bf5ae0636add76 /lib/db.php | |
parent | 5ffec927012a98cdcc409318dd1b2a264f071b83 (diff) | |
download | nextcloud-server-e533e82bc9526ef9869b20e99b745c210348218f.tar.gz nextcloud-server-e533e82bc9526ef9869b20e99b745c210348218f.zip |
Add sequence name in insertid to be more portable
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/db.php b/lib/db.php index 421b08c2320..c059f5ab336 100644 --- a/lib/db.php +++ b/lib/db.php @@ -224,6 +224,7 @@ class OC_DB { /** * @brief gets last value of autoincrement + * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix * @returns id * * MDB2 lastInsertID() @@ -231,9 +232,14 @@ class OC_DB { * Call this method right after the insert command or other functions may * cause trouble! */ - public static function insertid(){ + public static function insertid($table=null){ self::connect(); - return self::$connection->lastInsertId(); + if($table !== null){ + $prefix = OC_Config::getValue( "dbtableprefix", "oc_" ); + $suffix = OC_Config::getValue( "dbsequencesuffix", "_id_seq" ); + $table = str_replace( '*PREFIX*', $prefix, $table ); + } + return self::$connection->lastInsertId($table.$suffix); } /** |