The following code explains for itself in using simple transaction with Doctrine 1.x ORM in Symfony.

$conn = sfContext::getInstance()->getDatabaseManager()->getDatabase('doctrine')->getDoctrineConnection();
 
try {
	$conn->beginTransaction();
 
	// The part where you want to do transaction. Add your codes here
 
	// Commit the transaction when done
	$conn->commit();
 
} catch (Doctrine_Exception $e) {
	// Rollback if transaction fail
	$conn->rollback();
} 

Please help expand this article

Discuss the article:

Comment anonymously. Login not required.

Share!