summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2009-08-04 08:22:41 +0000
committeralecpl <alec@alec.pl>2009-08-04 08:22:41 +0000
commit6b7e8e705a32088a7cb7094eb3204714442cd4e6 (patch)
tree0554e286dfc5c3a895afbc91ac62583d78aaca9f /program
parentdbfceb4b5c81d6627fe549ae4a0a8ee24ac52093 (diff)
- Use sequence names only with PostgreSQL (#1486018)
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_contacts.php2
-rw-r--r--program/include/rcube_mdb2.php10
-rw-r--r--program/include/rcube_user.php4
3 files changed, 10 insertions, 6 deletions
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index e85c865f2..a931845ae 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -271,7 +271,7 @@ class rcube_contacts extends rcube_addressbook
VALUES (".intval($this->user_id).", ".$this->db->now().", 0, ".join(', ', $a_insert_values).")"
);
- $insert_id = $this->db->insert_id(get_sequence_name('contacts'));
+ $insert_id = $this->db->insert_id('contacts');
}
return $insert_id;
diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php
index 12f3c1652..2fce391d9 100644
--- a/program/include/rcube_mdb2.php
+++ b/program/include/rcube_mdb2.php
@@ -321,16 +321,20 @@ class rcube_mdb2
* Get last inserted record ID
* For Postgres databases, a sequence name is required
*
- * @param string Sequence name for increment
+ * @param string Table name (to find the incremented sequence)
* @return mixed ID or FALSE on failure
* @access public
*/
- function insert_id($sequence = '')
+ function insert_id($table = '')
{
if (!$this->db_handle || $this->db_mode=='r')
return FALSE;
- $id = $this->db_handle->lastInsertID($sequence);
+ // find sequence name
+ if ($table && $this->db_provider == 'pgsql')
+ $table = get_sequence_name($table);
+
+ $id = $this->db_handle->lastInsertID($table);
return $this->db_handle->isError($id) ? null : $id;
}
diff --git a/program/include/rcube_user.php b/program/include/rcube_user.php
index d933aa3c9..54a76c5ab 100644
--- a/program/include/rcube_user.php
+++ b/program/include/rcube_user.php
@@ -231,7 +231,7 @@ class rcube_user
call_user_func_array(array($this->db, 'query'),
array_merge(array($sql), $insert_values));
- return $this->db->insert_id(get_sequence_name('identities'));
+ return $this->db->insert_id('identities');
}
@@ -386,7 +386,7 @@ class rcube_user
strip_newlines($data['alias'] ? $data['alias'] : $user_email),
$_SESSION['language']);
- if ($user_id = $dbh->insert_id(get_sequence_name('users')))
+ if ($user_id = $dbh->insert_id('users'))
{
// create rcube_user instance to make plugin hooks work
$user_instance = new rcube_user($user_id);