SoftDelete & related models

When I use SoftDelete only model - the parent is marked as deleted. Records in tables that contain foreign key remain intact. Foreign keys are labeled: Relation :: ACTION_CASCADE.

Without SoftDelete everything is ok.

What is the problem?



81.3k

As soft delete does not trigger the 'delete' itself, related records keep untouched. You can see the code of that behavior here: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/mvc/model/behavior/softdelete.zep#L37



2.1k

I use Phalcon 1.3.2 version. I think that this concept is inconsistent. Relationships between models should be separated of the mechanisms its removal.

At the moment I solved the problem using custom behaviors and methods provided by Phalcon\Mvc\Model\Manager.

By the way, Phalcon\Mvc\Model\Resultset\Simple::delete() not take into account added to the model behaviors. This is misleading, because specifying the behavior we think in terms of events, rather than specific methods and types of objects..