News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPMaster.com:
Implementing a Unit of Work - Handling Domain Objects through a Transactional Model
May 31, 2012 @ 09:53:03

In this new post to PHPMaster.com, Alejandro Gervasio looks at working with domain objects via a transactional system using the Unit of Work design pattern.

In fact, it's feasible to wrap collections of domain objects inside a fairly flexible business transactional model and just perform several database writes/deletes in one go, therefore avoiding having to break down the process into more atomic and expensive database calls, which always lead to the session-per-operation antipattern. Moreover, this transaction-based mechanism rests on the academic formalities of a design pattern commonly known as Unit of Work (UOW), and its implementation in several popular enterprise-level packages, such as Hibernate, is quite prolific and prosperous.

He shows how to implement the "Unit of Work" design pattern via a "UnitOfWorkInterface" and a "UnitOfWork" class that implements it. The class provides methods for things like entity handling (CRUD operations) and working with the data mapper for the transactions. He also includes the code to implement the data mapper, a layer on top of a PDO-based interface that also provides CRUD operations for the data records. From this, he defines a domain model, "User", and shows how to create a new user, register it with the UnitOfWork instance and do things like update a property, delete the record and pull out the user's information.

0 comments voice your opinion now!
unitofwork designpattern domain model tutorial


blog comments powered by Disqus

Similar Posts

IBM developerWorks: Java and PHP technology on AIX - Integrate the Java business application w/ DB2

PHPMaster.com: Build a CRUD App with Yii in Minutes

Nexen.net: PHP statistics for March 2007

Felix Geisendorfer's Blog: Validating the cleaned output of HtmlHelper::dateTimeOptionTag()

Felix Geisendorfer's Blog: 10 Days of Free Dessert!


Community Events











Don't see your event here?
Let us know!


introduction facebook series opinion release composer security database hack hhvm component podcast package framework unittest symfony2 install application language performance

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework