fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15352] fix transaction


From: sigurdne
Subject: [Fmsystem-commits] [15352] fix transaction
Date: Fri, 1 Jul 2016 08:33:28 +0000 (UTC)

Revision: 15352
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15352
Author:   sigurdne
Date:     2016-07-01 08:33:28 +0000 (Fri, 01 Jul 2016)
Log Message:
-----------
fix transaction

Modified Paths:
--------------
    trunk/booking/inc/class.socommon.inc.php

Modified: trunk/booking/inc/class.socommon.inc.php
===================================================================
--- trunk/booking/inc/class.socommon.inc.php    2016-07-01 08:12:13 UTC (rev 
15351)
+++ trunk/booking/inc/class.socommon.inc.php    2016-07-01 08:33:28 UTC (rev 
15352)
@@ -31,7 +31,9 @@
                );
                protected
                        $cols,
-                       $auto_fields;
+                       $auto_fields,
+                       $global_lock = false;
+
                protected static $AUTO_FIELD_ACTIONS = array('add' => true, 
'update' => true);
 
                public function __construct( $table_name, $fields )
@@ -641,7 +643,15 @@
                {
                        $values = 
$this->marshal_field_values($this->get_table_values($entry, __FUNCTION__));
 
-                       $this->db->transaction_begin();
+                       if ($this->db->get_transaction())
+                       {
+                               $this->global_lock = true;
+                       }
+                       else
+                       {
+                               $this->db->transaction_begin();
+                       }
+
                        $this->db->query('INSERT INTO ' . $this->table_name . ' 
(' . join(',', array_keys($values)) . ') VALUES(' . join(',', $values) . ')', 
__LINE__, __FILE__);
                        $id = $this->db->get_last_insert_id($this->table_name, 
'id');
                        foreach ($this->fields as $field => $params)
@@ -701,7 +711,10 @@
                                }
                        }
 
-                       $this->db->transaction_commit();
+                       if (!$this->global_lock)
+                       {
+                               $this->db->transaction_commit();
+                       }
 
                        $receipt['id'] = $id;
                        $receipt['message'][] = array('msg' => lang('Entity %1 
has been saved', $receipt['id']));




reply via email to

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