diff options
Diffstat (limited to 'lib/db.php')
-rw-r--r-- | lib/db.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/db.php b/lib/db.php index 421b08c2320..bcfe320665f 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); } /** @@ -486,7 +492,7 @@ class PDOStatementWrapper{ } /** - * make exucute return the result instead of a bool + * make execute return the result instead of a bool */ public function execute($input=array()){ $this->lastArguments=$input; |