Transactions on DB_DataObject
| From: | Dan Rossi | Date: | Wed, 20 Apr 2005 04:37:17 +0000 |
| Subject: | Transactions on DB_DataObject | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-18810@lists.php.net to get a copy of this message | ||
Hi there I have been looking into the transactions for DB_DataObject I have made a diff of some changes to _query. Basically I have seperated the transactions from the _query and into specified functions. It handles features for both DB and MDB. I am however still having a trivial problem when to rollback on a problem, how do we ever know when a fault arises especially power power or the such. My implementation works I have tested a begin and then rollback befoire a commit and nothing goes in. I however need to test this on an update hehehe :) This is how i have to set it up currently for the DO's.
here is a link to the diff lemme know if this is a BC break ..
www.electroteque.org/pear/DB_DataObject.diff
$this->begin();
$issueID = parent::insert();
if ($issueID) {
$issue_threads = DB_DataObject::factory('issue_threads');
$issue_threads->setFrom($_POST);
$issue_threads->fromValue('issueID',$issueID);
$issue_threads->fromValue('date_added',DB_DataObject_Cast::sql("NOW()"));
$issue_threads->insert();
$this->commit();
return $issueID;
} else {
$this->rollBack();
}