summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/bookmarks/ajax/addBookmark.php8
-rw-r--r--apps/calendar/lib/calendar.php4
-rw-r--r--apps/calendar/lib/object.php4
-rw-r--r--apps/contacts/lib/addressbook.php4
-rw-r--r--apps/contacts/lib/vcard.php4
-rw-r--r--apps/media/lib_collection.php2
-rw-r--r--lib/db.php10
7 files changed, 18 insertions, 18 deletions
diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php
index 3975fd15f81..45b16ae5fa6 100644
--- a/apps/bookmarks/ajax/addBookmark.php
+++ b/apps/bookmarks/ajax/addBookmark.php
@@ -54,13 +54,7 @@ $params=array(
);
$query->execute($params);
-if($CONFIG_DBTYPE == 'pgsql')
-{
- $query = OC_DB::prepare("SELECT currval('*PREFIX*bookmarks_id_seq')");
- $b_id = $query->execute()->fetchOne();
-} else {
- $b_id = OC_DB::insertid();
-}
+$b_id = OC_DB::insertid('*PREFIX*bookmarks');
if($b_id !== false) {
diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php
index c19c0e73c08..f6d40aa534e 100644
--- a/apps/calendar/lib/calendar.php
+++ b/apps/calendar/lib/calendar.php
@@ -111,7 +111,7 @@ class OC_Calendar_Calendar{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_calendar');
}
/**
@@ -131,7 +131,7 @@ class OC_Calendar_Calendar{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*calendar_calendars (userid,displayname,uri,ctag,calendarorder,calendarcolor,timezone,components) VALUES(?,?,?,?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,1,$order,$color,$timezone,$components));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_calendars');
}
/**
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index 0c3e497d4f2..33871cd3185 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -78,7 +78,7 @@ class OC_Calendar_Object{
OC_Calendar_Calendar::touchCalendar($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_objects');
}
/**
@@ -97,7 +97,7 @@ class OC_Calendar_Object{
OC_Calendar_Calendar::touchCalendar($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*calendar_objects');
}
/**
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 2e869d7de3b..87477ed7ed4 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -96,7 +96,7 @@ class OC_Contacts_Addressbook{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,$description,1));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_addressbooks');
}
/**
@@ -113,7 +113,7 @@ class OC_Contacts_Addressbook{
$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
$result = $stmt->execute(array($userid,$name,$uri,$description,1));
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_addressbooks');
}
/**
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
index 74bc0f92f1b..adfa32b6f5f 100644
--- a/apps/contacts/lib/vcard.php
+++ b/apps/contacts/lib/vcard.php
@@ -121,7 +121,7 @@ class OC_Contacts_VCard{
OC_Contacts_Addressbook::touch($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_cards');
}
/**
@@ -147,7 +147,7 @@ class OC_Contacts_VCard{
OC_Contacts_Addressbook::touch($id);
- return OC_DB::insertid();
+ return OC_DB::insertid('*PREFIX*contacts_cards');
}
/**
diff --git a/apps/media/lib_collection.php b/apps/media/lib_collection.php
index 571cb7e6850..caa3ac3f479 100644
--- a/apps/media/lib_collection.php
+++ b/apps/media/lib_collection.php
@@ -267,7 +267,7 @@ class OC_MEDIA_COLLECTION{
$query=self::$queries['addsong'];
}
$query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size));
- $songId=OC_DB::insertid();
+ $songId=OC_DB::insertid('*PREFIX*media_songs');
// self::setLastUpdated();
return self::getSongId($name,$artist,$album);
}
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);
}
/**