Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

Deletion of items managed by a DataObjectManager


6 Posts   1237 Views


20 October 2009 at 3:50am Community Member, 39 Posts

Hi there,

I have a DataObjectManager for the agency website I am developing which associated many brands with a client. I have on the portfolio page a drop-down for brands, which uses DataObject::get to retrieve all Brands. However I have noticed that when removing a Brand under the CMS this does not remove it from the database, and hence it still appears in the drop-down.

One solution would be to convert the Brand objects to extend page, so I could at least check for a ParentID, but you still have a problem with unnecessary database bloat with items in there which should be deleted.

Is there a better way?



20 October 2009 at 4:21am 4085 Posts

Deleting a record from the DOM should result in its removal from the database. I can't imagine why it wouldn't be executing that delete. Is that true for all of the objects you manage with DOM?


20 October 2009 at 4:33am Community Member, 39 Posts

Further to this, the problem actually occurs when I delete a client page, without first going through and deleting the brands from that client i.e reduncant brand objects are left over. The following query seems to work:

$brands = Dataobject::get("Brand","","Name Asc","RIGHT JOIN ClientPage ON Brand.ClientID = ClientPage.ID"

Anyone know of a solution to all of the redundant data/columns in the database once you start to delete stuff without going into PHPMyadmin or similar?


20 October 2009 at 4:45am 4085 Posts

You're expecting the deletion of a page to result in a cascade delete of objects related to it? It doesn't work that way. You haven't necessarily orphaned your Brand object by deleting the page that relates to it. The Brand record may get paired up with another ClientPage at some point. That relation is not one-to-one.


20 October 2009 at 9:44am Community Member, 39 Posts

Thanks for clarifying. The thing is though, the Brand object could never get paired up again, because there isn't the option to associate current objects with a new Client Page using the DMA? Maybe my OO/SQL isn't the best :)


20 October 2009 at 10:09am 4085 Posts

Then I would just use an onBeforeDelete() hook in your page class.

public function onBeforeDelete()