Remove entitles that never had parent - doctrine

31 views Asked by At

I use orphan Removal to remove entities that are orphaned but I could not find a way to remove entities that never had a parent.

For example, I build a house that has rooms, I delete the house, and orphan Removal will delete the room entities, all works good.

Second scenery, I build a room first, and save it to use it in building the house later. I never used it, I did not build the house and orphan Removal will not delete this entity for me.

What can I do to remove this kind of entities on a regular basis?

I searched the internet for solutions but could not find any. I'm new to programming so I was thinking that maybe I don't search for the right thing. Any directions or tips would be amazing. Thank you

1

There are 1 answers

0
ThomasL On

You could simply build a script that you execute everyday using cronjob on your server. If you use symfony, use console command as script to execute. This script would retrieve orphan from database en delete it.

In local, just execute the command.