[Svn] r2834 - in trunk/roundcubemail: . program/include

trac at roundcube.net trac at roundcube.net
Tue Aug 4 10:22:41 CEST 2009


Author: alec
Date: 2009-08-04 03:22:41 -0500 (Tue, 04 Aug 2009)
New Revision: 2834

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_contacts.php
   trunk/roundcubemail/program/include/rcube_mdb2.php
   trunk/roundcubemail/program/include/rcube_user.php
Log:
- Use sequence names only with PostgreSQL (#1486018)


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2009-08-04 07:00:19 UTC (rev 2833)
+++ trunk/roundcubemail/CHANGELOG	2009-08-04 08:22:41 UTC (rev 2834)
@@ -1,6 +1,7 @@
 CHANGELOG RoundCube Webmail
 ===========================
 
+- Use sequence names only with PostgreSQL (#1486018)
 - Re-designed User Preferences interface 
 - Fix MS SQL DDL (#1486020)
 - Fix rcube_mdb2.php: call to setCharset not implemented in mssql driver (#1486019)

Modified: trunk/roundcubemail/program/include/rcube_contacts.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_contacts.php	2009-08-04 07:00:19 UTC (rev 2833)
+++ trunk/roundcubemail/program/include/rcube_contacts.php	2009-08-04 08:22:41 UTC (rev 2834)
@@ -271,7 +271,7 @@
          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;

Modified: trunk/roundcubemail/program/include/rcube_mdb2.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_mdb2.php	2009-08-04 07:00:19 UTC (rev 2833)
+++ trunk/roundcubemail/program/include/rcube_mdb2.php	2009-08-04 08:22:41 UTC (rev 2834)
@@ -321,16 +321,20 @@
    * 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;
     }

Modified: trunk/roundcubemail/program/include/rcube_user.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_user.php	2009-08-04 07:00:19 UTC (rev 2833)
+++ trunk/roundcubemail/program/include/rcube_user.php	2009-08-04 08:22:41 UTC (rev 2834)
@@ -231,7 +231,7 @@
     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 @@
       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);

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list