Adatabasetransactionisaunitofinteractionwithadatabasemanagementsystemorsimilarsystemthatistreatedinacoherentandreliablewayindependentofothertransactionsthatmustbeeitherentirelycompletedoraborted.Ideally,adatabasesystemwillguaranteealloftheACID(Atomicity,Consistency,Isolation,andDurability)propertiesforeachtransaction.<ul><li><ahref="http://en.wikipedia.org/wiki/Atomicity">Atomicity</a>referstotheabilityoftheDBMStoguaranteethateitherallofthetasksofatransactionareperformedornoneofthemare.Thetransferoffundscanbecompletedoritcanfailforamultitudeofreasons,butatomicityguaranteesthatoneaccountwon't be debited if the other is not credited as well.</li></ul><ul><li><a href="http://en.wikipedia.org/wiki/Database_consistency" title="Database consistency">Consistency</a> refers to the database being in a legal state when the transaction begins and when it ends. This means that a transaction can'tbreaktherules,or<i>integrityconstraints</i>,ofthedatabase.Ifanintegrityconstraintstatesthatallaccountsmusthaveapositivebalance,thenanytransactionviolatingthisrulewillbeaborted.</li></ul><ul><li><ahref="http://en.wikipedia.org/wiki/Isolation_%28computer_science%29"title="Isolation (computer science)">Isolation</a>referstotheabilityoftheapplicationtomakeoperationsinatransactionappearisolatedfromallotheroperations.Thismeansthatnooperationoutsidethetransactioncaneverseethedatainanintermediatestate;abankmanagercanseethetransferredfundsononeaccountortheother,butneveronboth—evenifsheranherquerywhilethetransferwasstillbeingprocessed.Moreformally,isolationmeansthetransactionhistory(or<ahref="http://en.wikipedia.org/wiki/Schedule_%28computer_science%29"title="Schedule (computer science)">schedule</a>)is<ahref="http://en.wikipedia.org/wiki/Serializability"title="Serializability">serializable</a>.Forperformancereasons,thisabilityisthemostoftenrelaxedconstraint.Seethe<ahref="/wiki/Isolation_%28computer_science%29"title="Isolation (computer science)">isolation</a>articleformoredetails.</li></ul><ul><li><ahref="http://en.wikipedia.org/wiki/Durability_%28computer_science%29"title="Durability (computer science)">Durability</a>referstotheguaranteethatoncetheuserhasbeennotifiedofsuccess,thetransactionwillpersist,andnotbeundone.Thismeansitwillsurvivesystemfailure,andthatthe<ahref="http://en.wikipedia.org/wiki/Database_system"title="Database system">databasesystem</a>hascheckedtheintegrityconstraintsandwon'tneedtoabortthetransaction.Typically,alltransactionsarewrittenintoa<ahref="http://en.wikipedia.org/wiki/Database_log"title="Database log">log</a>thatcanbeplayedbacktorecreatethesystemtoitsstaterightbeforethefailure.Atransactioncanonlybedeemedcommittedafteritissafelyinthelog.</li></ul>-<i>from<ahref="http://www.wikipedia.org">wikipedia</a></i><br\><br\>InDoctrinealloperationsarewrappedintransactionsbydefault.TherearesomethingsthatshouldbenoticedabouthowDoctrineworksinternally:<ul><li>Doctrineusesapplicationleveltransactionnesting.</ul><ul><li>DoctrinealwaysexecutesINSERT/UPDATE/DELETEqueriesattheendoftransaction(whentheoutermostcommitiscalled).Theoperationsareperformedinthefollowingorder:allinserts,allupdatesandlastalldeletes.Doctrineknowshowtooptimizethedeletessothatdeleteoperationsofthesamecomponentaregatheredinonequery.</ul>