phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] api/accounts/class.accounts_sql.php, 1.1.1.1.2.17


From: nomail
Subject: [Phpgroupware-cvs] api/accounts/class.accounts_sql.php, 1.1.1.1.2.17
Date: Sun, 23 May 2004 09:57:38 -0000

Update of /api/accounts
Modified Files:
        Branch: proposal-branch
          class.accounts_sql.php

date: 2004/05/07 00:12:34;  author: jengo;  state: Exp;  lines: +10 -15

Log Message:
- Added proper support for last insert id, using the ADODB build in sequences.  
This will allow better cross database support.
  Currently, MySQL will create a seperate table for each table that uses 
sequences, I don't like this.  I would prefear to create a
single generic table for sequences on databases that don't have native support 
for sequences.  For now, this is fine.
=====================================================================
Index: api/accounts/class.accounts_sql.php
diff -u api/accounts/class.accounts_sql.php:1.1.1.1.2.16 
api/accounts/class.accounts_sql.php:1.1.1.1.2.17
--- api/accounts/class.accounts_sql.php:1.1.1.1.2.16    Fri Apr 23 04:28:21 2004
+++ api/accounts/class.accounts_sql.php Fri May  7 00:12:34 2004
@@ -50,16 +50,6 @@
                        $this->data = $this->read_repository();
                }
 
-               function __sleep()
-               {
-                       // stub so its gets cache'd. No cleanup needed.
-               }
-               
-               function __wakeup()
-               {
-
-               }
-
                function fill_phpgw_data()
                {
                        if($GLOBALS['phpgw']->session->is_anon() && 
!isset($this->data['id']))
@@ -362,8 +352,13 @@
                                }
                        }
                        $dbresult = $GLOBALS['phpgw']->db->Execute("SELECT 
account_id FROM phpgw_accounts WHERE account_lid='" . $args['account_lid']."'");
-                       if($dbresult->EOF)
-                       {                       
+                       if ($dbresult->EOF)
+                       {
+                               // FIXME:  This can be a race condition, 98% of 
the time it won't happen
+                               // unless its a fairly large install thats 
registering tons of users
+                               // all the time.  I am not sure if I want to 
add a table lock here
+                               // table locks only slow things down.  This 
will need to be fixed in the future. (jengo)
+                               $account_id = 
$GLOBALS['phpgw']->db->genid('phpgw_accounts_account_id_seq');
                                $sql = "INSERT INTO
                                                phpgw_accounts
                                                (
@@ -387,8 +382,8 @@
                                                )";
 
                                $GLOBALS['phpgw']->db->Execute($sql);
-                               $dbresult = 
$GLOBALS['phpgw']->db->Execute("SELECT account_id FROM phpgw_accounts WHERE 
account_lid='" . $args['account_lid']."'");
-                               return $dbresult->fields['account_id'];
+
+                               return ($GLOBALS['phpgw']->db->affected_rows() 
? $account_id : False);
                        }
                        else
                        {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]