Does Propel know when an object was softly deleted so that children can still show their remote parent?

I gently delete objects in a MySQL database and using Propel ORM. I got a soft delete to work, but due to the loss of my forced parent-child relationship, since the actual rows are not deleted.

Is there any way for Propel to find out that the record was gently deleted when accessing it, so that a null-reference exception is not thrown? Thus, although the parent has been deleted, its child can still read its relationship, but when the child is updated or a new child is created, the remote parent is not available.

For instance,

The book has an AuthorId, and if an author owned by AuthorId is gently removed, then:

$book->getAuthor();

will return the correct author (view only). However, if a new book has been added, an author who has been gently deleted is not available for selection.

Does anyone know if this feature is built into Propel?

+3
source share
3 answers

Soft removal is a broken abstraction. Instead, you should use archived behavior (see Why on the Propel blog: http://propelorm.org/blog/2011/08/29/introducing-archivable-behavior-and-why-soft-delete-is-deprecated.html )

+1
source

, , (, , ), . Propel, ( ):

$c = new Criteria();
$c->getNewCriterion(self::AUTHOR_ID, $parentId);
return self::doSelect($c, $connection);
0

. , . , , , isEnabled.

AuthorQuery,

AuthorQuery::create->filterByisEnabled()
                   ->find();

If the object will still be used in the application, removing it is really impractical. The soft deletion functionality is for reference only or error recovery.

0
source

Source: https://habr.com/ru/post/1738559/


All Articles