News Feed
Sections




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

Jani Hartikainen's Blog:
How to create Doctrine 1-style Soft-Delete in Doctrine 2
December 06, 2010 @ 13:02:08

Jani Hartikainen has posted his technique for making the Doctrine version 1 style "soft delete" in your Doctrine 2 powered application.

Doctrine 1 has the concept of behaviors which you could add to your models. One of these was the soft-delete behavior, which allowed you to "delete" records without really deleting them. Doctrine 2 does not have behaviors due to various reasons. However, I needed a way to have a model which worked like soft-delete. Let's see one approach to creating such behavior in Doctrine 2.

He introduces the idea of a "soft delete" - essentially a flag that gets set to let the rest of the application think that row is essentially deleted. He shows you how to create the similar functionality via a repository that filters the data for you. He includes code to help you along, defining the find/findOneBy/findBy and the example repository that lets you set an "is deleted" property on the object.

0 comments voice your opinion now!
doctrine soft delete repository filter


blog comments powered by Disqus

Similar Posts

PHPMaster.com: Exploring PHP’s IMAP Library, Part 2

Richard Thomas' Blog: First jQPie release, 0.1

Submission: Taylor Luk Releases H2o Templating System (Django-inspired)

Matthew Weir O'Phinney's Blog: Phly Darcs Repository online

PHPMaster.com: PHP Security: Cross-Site Scripting Attacks (XSS)


Community Events





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


application threedevsandamaybe interview framework release api code series language library developer wordpress bugfix list configure laravel introduction community podcast project

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