Skip to content

Commit

Permalink
Fixes: make sure not to use nested transactions and that object varia…
Browse files Browse the repository at this point in the history
…ble exists before checking if it's value was changed.

git-svn-id: http://voip.null.ro/svn/ansql/trunk@128 dbfed7de-b0aa-0410-b6a1-c7e608b77fc9
  • Loading branch information
monica committed Dec 16, 2014
1 parent 1940b56 commit 595c1bc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class Database
{
protected static $_connection = true;
protected static $_object_model = "Model";
public static $_in_transaction = false;

// this library uses mostly postgresql types
// if type is not in the below list make sure that given type of a variables mathches real type in database
Expand Down Expand Up @@ -264,6 +265,9 @@ public static function connect($connection_index="")
public static function transaction()
{
Debug::func_start(__METHOD__,func_get_args(),"framework");
if (self::$_in_transaction===true)
return;
self::$_in_transaction = true;
return Database::query("BEGIN WORK");
}

Expand All @@ -273,6 +277,7 @@ public static function transaction()
public static function rollback()
{
Debug::func_start(__METHOD__,func_get_args(),"framework");
self::$_in_transaction = false;
return Database::query("ROLLBACK");
}

Expand All @@ -282,6 +287,7 @@ public static function rollback()
public static function commit()
{
Debug::func_start(__METHOD__,func_get_args(),"framework");
self::$_in_transaction = false;
return Database::query("COMMIT");
}

Expand Down Expand Up @@ -1368,10 +1374,11 @@ public function setParams($params)
$this->_modified_col = array();

foreach($params as $param_name=>$param_value) {
if($this->{$param_name} != $param_value)
$this->_modified_col[$param_name] = true;
if($this->variable($param_name))
if($this->variable($param_name)) {
if($this->{$param_name} != $param_value)
$this->_modified_col[$param_name] = true;
$this->{$param_name} = $param_value;
}
}
}

Expand Down

0 comments on commit 595c1bc

Please sign in to comment.