Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Request #2812 support for nested transactions (mysql)
Submitted: 2004-11-23 15:19 UTC
From: andre dot steffens at adress-research dot de Assigned: danielc
Status: Bogus Package: DB
PHP Version: 4.3.9 OS: Win2k
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 44 + 27 = ?

 
 [2004-11-23 15:19 UTC] andre dot steffens at adress-research dot de
Description: ------------ It would be nice to have a counter which is increment on 'begin' and decrement on 'rollback' or 'commit'. Only if the counter is 0 a commit or rollback is really done. Also you can set a var like transaction_fails. A main transaction only can commit if all sub transactions are ok. I think this function could be implemented in the methods commit(), rollback() and begin() What do you think about it? Thx Andre

Comments

 [2004-12-03 16:35 UTC] andre dot steffens at adress-research dot de
What do you think about the following solution? // {{{ begin() function begin() { if ($this->transaction_opcount == 0) { if ($this->isError($x = $this->selectdb())) return $x; $result = @mysql_query('BEGIN', $this->connection); if (!$result) { return $this->mysqlRaiseError(); } $this->transaction_fail = false; } $this->transaction_opcount++; return DB_OK; } // }}} // {{{ commit() function commit() { if ($this->transaction_fail) { return $this->rollback(); } if ($this->transaction_opcount > 0) { $this->transaction_opcount--; if ($this->transaction_opcount == 0) { if ($this->isError($x = $this->selectdb())) { return $x; } $result = @mysql_query('COMMIT', $this->connection); $result = @mysql_query('SET AUTOCOMMIT=1', $this->connection); if (!$result) { return $this->mysqlRaiseError(); } $this->transaction_fail = false; } } return DB_OK; } // }}} // {{{ rollback() function rollback() { if ($this->transaction_opcount > 0) { $this->transaction_opcount--; if ($this->transaction_opcount == 0) { if ($this->isError($x = $this->selectdb())) { return $x; } $result = @mysql_query('ROLLBACK', $this->connection); $result = @mysql_query('SET AUTOCOMMIT=1', $this->connection); if (!$result) { return $this->mysqlRaiseError(); } $this->transaction_fail = false; } else $this->transaction_fail = true; } return DB_OK; } // }}
 [2005-11-20 19:38 UTC] danielc
To the best of my knowledge, MySQL doesn't support nested transactions.