We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Delete related records after SoftDelete


Sometimes I need delete related records after SoftDelete.

This code works fine:

$this->addBehavior(new SoftDelete(
                'field' => 'is_deleted',
                'value' => AuthUsers::DELETED

But cascade delete dont work (when soft delete removed its work):

            "au_uuid", "Repo\AuthUsersRoles",
                "foreignKey" => array(
                    'action' => Relation::ACTION_CASCADE

Can somebody helps to me? Thanks.


So the related rows should be actually deleted? (Not soft-deleted?) (Well, how that should behave should of course depend on the related Model configuration) Got it working? Seems to be a bug otherwise?

Yes they should be deleted(i think so) depends on model behavior. If there described delete cascade, then delete it. Of course there is can be behavior with soft delete.

At now, I don't use this feature.


edited May '14

Ok, cool, thx for your reply. I just started working with this feaure, so I'll keep an eye out on the issue... ;-)

Phalcon doesn't take "soft delete" as a truely "delete", it's actually a update. So soft delete won't trigger any delete events, like beforeDelete() or afterDelete(). And it won't trigger cascade delete, too.

Sorry, my English is poor. I hope you understand what I mean.